@@ -11,20 +11,20 @@ |
||
11 | 11 | */ |
12 | 12 | class RegistrationsAdmin extends CoreAdmin |
13 | 13 | { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - const REGISTRATION_STATUS_NOT_APPROVED = 'RNA'; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + const REGISTRATION_STATUS_NOT_APPROVED = 'RNA'; |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - const REGISTRATION_STATUS_APPROVED = 'RAP'; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + const REGISTRATION_STATUS_APPROVED = 'RAP'; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP'; |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP'; |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -42,51 +42,51 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param \Registrations_Admin_Page $admin_page |
44 | 44 | */ |
45 | - public function __construct( $admin_page ) { |
|
46 | - parent::__construct( $admin_page ); |
|
45 | + public function __construct($admin_page) { |
|
46 | + parent::__construct($admin_page); |
|
47 | 47 | $this->_status = $this->_admin_page->get_registration_status_array(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | 52 | protected function _setup_data() { |
53 | - $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page ) |
|
54 | - : $this->_admin_page->get_event_attendees( $this->_per_page, false, true ); |
|
53 | + $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
54 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
55 | 55 | $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
56 | 56 | $this->_per_page, |
57 | 57 | true |
58 | - ) : $this->_admin_page->get_event_attendees( $this->_per_page, true, true ); |
|
58 | + ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | 63 | protected function _set_properties() { |
64 | - $evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null; |
|
64 | + $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
65 | 65 | $this->_wp_list_args = array( |
66 | - 'singular' => __( 'registrant', 'event_espresso' ), |
|
67 | - 'plural' => __( 'registrants', 'event_espresso' ), |
|
66 | + 'singular' => __('registrant', 'event_espresso'), |
|
67 | + 'plural' => __('registrants', 'event_espresso'), |
|
68 | 68 | 'ajax' => true, |
69 | 69 | 'screen' => $this->_admin_page->get_current_screen()->id, |
70 | 70 | ); |
71 | 71 | $columns = array(); |
72 | 72 | //$columns['_Reg_Status'] = ''; |
73 | - if ( ! empty( $evt_id ) ) { |
|
73 | + if ( ! empty($evt_id)) { |
|
74 | 74 | $columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text |
75 | 75 | $this->_has_checkbox_column = true; |
76 | 76 | } |
77 | 77 | $this->_columns = array( |
78 | 78 | '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
79 | - 'ATT_name' => __( 'Registrant', 'event_espresso' ), |
|
80 | - 'ATT_email' => __( 'Email Address', 'event_espresso' ), |
|
81 | - 'Event' => __( 'Event', 'event_espresso' ), |
|
82 | - 'PRC_name' => __( 'TKT Option', 'event_espresso' ), |
|
83 | - '_REG_final_price' => __( 'Price', 'event_espresso' ), |
|
84 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
85 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
79 | + 'ATT_name' => __('Registrant', 'event_espresso'), |
|
80 | + 'ATT_email' => __('Email Address', 'event_espresso'), |
|
81 | + 'Event' => __('Event', 'event_espresso'), |
|
82 | + 'PRC_name' => __('TKT Option', 'event_espresso'), |
|
83 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
84 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
85 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
86 | 86 | ); |
87 | - $this->_columns = array_merge( $columns, $this->_columns ); |
|
87 | + $this->_columns = array_merge($columns, $this->_columns); |
|
88 | 88 | $this->_primary_column = '_REG_att_checked_in'; |
89 | - if ( ! empty( $evt_id ) |
|
89 | + if ( ! empty($evt_id) |
|
90 | 90 | && EE_Registry::instance()->CAP->current_user_can( |
91 | 91 | 'ee_read_registrations', |
92 | 92 | 'espresso_registrations_registrations_reports', |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'extra_request' => |
100 | 100 | array( |
101 | 101 | 'EVT_ID' => $evt_id, |
102 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ), |
|
102 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
103 | 103 | ), |
104 | 104 | ), |
105 | 105 | ); |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | true, |
141 | 141 | $this |
142 | 142 | ) |
143 | - ? array( 'ATT_lname' => true ) |
|
144 | - : array( 'ATT_fname' => true ), |
|
145 | - 'Event' => array( 'Event.EVT.Name' => false ), |
|
143 | + ? array('ATT_lname' => true) |
|
144 | + : array('ATT_fname' => true), |
|
145 | + 'Event' => array('Event.EVT.Name' => false), |
|
146 | 146 | ); |
147 | 147 | $this->_hidden_columns = array(); |
148 | - $this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id ); |
|
148 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
149 | 149 | $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
150 | 150 | } |
151 | 151 | |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | * @param \EE_Registration $item |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - protected function _get_row_class( $item ) { |
|
159 | - $class = parent::_get_row_class( $item ); |
|
158 | + protected function _get_row_class($item) { |
|
159 | + $class = parent::_get_row_class($item); |
|
160 | 160 | //add status class |
161 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
162 | - if ( $this->_has_checkbox_column ) { |
|
161 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
162 | + if ($this->_has_checkbox_column) { |
|
163 | 163 | $class .= ' has-checkbox-column'; |
164 | 164 | } |
165 | 165 | return $class; |
@@ -173,61 +173,61 @@ discard block |
||
173 | 173 | */ |
174 | 174 | protected function _get_table_filters() { |
175 | 175 | $filters = $where = array(); |
176 | - $current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0; |
|
177 | - if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) { |
|
176 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
177 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
178 | 178 | //this means we don't have an event so let's setup a filter dropdown for all the events to select |
179 | 179 | //note possible capability restrictions |
180 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
181 | - $where['status**'] = array( '!=', 'private' ); |
|
180 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
181 | + $where['status**'] = array('!=', 'private'); |
|
182 | 182 | } |
183 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
183 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
184 | 184 | $where['EVT_wp_user'] = get_current_user_id(); |
185 | 185 | } |
186 | 186 | $events = EEM_Event::instance()->get_all( |
187 | 187 | array( |
188 | 188 | $where, |
189 | - 'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ), |
|
189 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
190 | 190 | ) |
191 | 191 | ); |
192 | 192 | $evts[] = array( |
193 | 193 | 'id' => 0, |
194 | - 'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ), |
|
194 | + 'text' => __('To toggle Check-in status, select an event', 'event_espresso'), |
|
195 | 195 | ); |
196 | 196 | $checked = 'checked'; |
197 | 197 | /** @var EE_Event $evt */ |
198 | - foreach ( $events as $evt ) { |
|
198 | + foreach ($events as $evt) { |
|
199 | 199 | //any registrations for this event? |
200 | - if ( ! $evt->get_count_of_all_registrations() ) { |
|
200 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | $evts[] = array( |
204 | 204 | 'id' => $evt->ID(), |
205 | - 'text' => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get( 'EVT_name' ), $evt), |
|
205 | + 'text' => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get('EVT_name'), $evt), |
|
206 | 206 | 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
207 | 207 | ); |
208 | - if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) { |
|
208 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
209 | 209 | $checked = ''; |
210 | 210 | } |
211 | 211 | } |
212 | 212 | $event_filter = '<div class="ee-event-filter">'; |
213 | - $event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID ); |
|
213 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
214 | 214 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
215 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
216 | - $event_filter .= __( 'Hide Expired Events', 'event_espresso' ); |
|
215 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
216 | + $event_filter .= __('Hide Expired Events', 'event_espresso'); |
|
217 | 217 | $event_filter .= '</span>'; |
218 | 218 | $event_filter .= '</div>'; |
219 | 219 | $filters[] = $event_filter; |
220 | 220 | } |
221 | - if ( ! empty( $this->_dtts_for_event ) ) { |
|
221 | + if ( ! empty($this->_dtts_for_event)) { |
|
222 | 222 | //DTT datetimes filter |
223 | - $this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0; |
|
224 | - if ( count( $this->_dtts_for_event ) > 1 ) { |
|
225 | - $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
|
226 | - foreach ( $this->_dtts_for_event as $dtt ) { |
|
223 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
224 | + if (count($this->_dtts_for_event) > 1) { |
|
225 | + $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
226 | + foreach ($this->_dtts_for_event as $dtt) { |
|
227 | 227 | $datetime_string = $dtt->name(); |
228 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
229 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
230 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
228 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
229 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
230 | + $dtts[$dtt->ID()] = $datetime_string; |
|
231 | 231 | } |
232 | 232 | $input = new EE_Select_Input( |
233 | 233 | $dtts, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | $filters[] = $input->get_html_for_input(); |
241 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
241 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | return $filters; |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @throws \EE_Error |
258 | 258 | */ |
259 | 259 | protected function _get_total_event_attendees() { |
260 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false; |
|
260 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
261 | 261 | $DTT_ID = $this->_cur_dtt_id; |
262 | 262 | $query_params = array(); |
263 | - if ( $EVT_ID ) { |
|
263 | + if ($EVT_ID) { |
|
264 | 264 | $query_params[0]['EVT_ID'] = $EVT_ID; |
265 | 265 | } |
266 | 266 | //if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
267 | - if ( $DTT_ID ) { |
|
267 | + if ($DTT_ID) { |
|
268 | 268 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
269 | 269 | } |
270 | 270 | $status_ids_array = apply_filters( |
271 | 271 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
272 | - array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) |
|
272 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
273 | 273 | ); |
274 | - $query_params[0]['STS_ID'] = array( 'IN', $status_ids_array ); |
|
275 | - return EEM_Registration::instance()->count( $query_params ); |
|
274 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
275 | + return EEM_Registration::instance()->count($query_params); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @param \EE_Registration $item |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function column__Reg_Status( EE_Registration $item ) { |
|
285 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
284 | + public function column__Reg_Status(EE_Registration $item) { |
|
285 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>'; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @return string |
293 | 293 | * @throws \EE_Error |
294 | 294 | */ |
295 | - public function column_cb( $item ) { |
|
296 | - return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() ); |
|
295 | + public function column_cb($item) { |
|
296 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -305,20 +305,20 @@ discard block |
||
305 | 305 | * @return string |
306 | 306 | * @throws \EE_Error |
307 | 307 | */ |
308 | - public function column__REG_att_checked_in( EE_Registration $item ) { |
|
308 | + public function column__REG_att_checked_in(EE_Registration $item) { |
|
309 | 309 | $attendee = $item->attendee(); |
310 | 310 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
311 | 311 | |
312 | - if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) { |
|
312 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
313 | 313 | $latest_related_datetime = $item->get_latest_related_datetime(); |
314 | - if ( $latest_related_datetime instanceof EE_Datetime ) { |
|
314 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
315 | 315 | $this->_cur_dtt_id = $latest_related_datetime->ID(); |
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | - $checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id ); |
|
320 | - $nonce = wp_create_nonce( 'checkin_nonce' ); |
|
321 | - $toggle_active = ! empty ( $this->_cur_dtt_id ) |
|
319 | + $checkinstatus = $item->check_in_status_for_datetime($this->_cur_dtt_id); |
|
320 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
321 | + $toggle_active = ! empty ($this->_cur_dtt_id) |
|
322 | 322 | && EE_Registry::instance()->CAP->current_user_can( |
323 | 323 | 'ee_edit_checkin', |
324 | 324 | 'espresso_registrations_toggle_checkin_status', |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | ) |
327 | 327 | ? ' clickable trigger-checkin' |
328 | 328 | : ''; |
329 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
330 | - return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"' |
|
331 | - . ' data-_regid="' . $item->ID() . '"' |
|
332 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
333 | - . ' data-nonce="' . $nonce . '">' |
|
329 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
330 | + return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'"' |
|
331 | + . ' data-_regid="'.$item->ID().'"' |
|
332 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
333 | + . ' data-nonce="'.$nonce.'">' |
|
334 | 334 | . '</span>' |
335 | 335 | . $mobile_view_content; |
336 | 336 | } |
@@ -342,21 +342,21 @@ discard block |
||
342 | 342 | * @return mixed|string|void |
343 | 343 | * @throws \EE_Error |
344 | 344 | */ |
345 | - public function column_ATT_name( EE_Registration $item ) { |
|
345 | + public function column_ATT_name(EE_Registration $item) { |
|
346 | 346 | $attendee = $item->attendee(); |
347 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
348 | - return __( 'No contact record for this registration.', 'event_espresso' ); |
|
347 | + if ( ! $attendee instanceof EE_Attendee) { |
|
348 | + return __('No contact record for this registration.', 'event_espresso'); |
|
349 | 349 | } |
350 | 350 | // edit attendee link |
351 | 351 | $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
352 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
352 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
353 | 353 | REG_ADMIN_URL |
354 | 354 | ); |
355 | 355 | $name_link = EE_Registry::instance()->CAP->current_user_can( |
356 | 356 | 'ee_edit_contacts', |
357 | 357 | 'espresso_registrations_edit_attendee' |
358 | 358 | ) |
359 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
359 | + ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
360 | 360 | . $item->attendee()->full_name() |
361 | 361 | . '</a>' |
362 | 362 | : $item->attendee()->full_name(); |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
365 | 365 | : ''; |
366 | 366 | //add group details |
367 | - $name_link .= ' ' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() ); |
|
367 | + $name_link .= ' '.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
368 | 368 | //add regcode |
369 | 369 | $link = EE_Admin_Page::add_query_args_and_nonce( |
370 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
370 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
371 | 371 | REG_ADMIN_URL |
372 | 372 | ); |
373 | 373 | $name_link .= '<br>'; |
@@ -376,50 +376,50 @@ discard block |
||
376 | 376 | 'view_registration', |
377 | 377 | $item->ID() |
378 | 378 | ) |
379 | - ? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
379 | + ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
380 | 380 | . $item->reg_code() |
381 | 381 | . '</a>' |
382 | 382 | : $item->reg_code(); |
383 | 383 | //status |
384 | 384 | $name_link .= '<br><span class="ee-status-text-small">'; |
385 | - $name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ); |
|
385 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
386 | 386 | $name_link .= '</span>'; |
387 | 387 | $actions = array(); |
388 | 388 | $DTT_ID = $this->_cur_dtt_id; |
389 | - $latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration |
|
389 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
390 | 390 | ? $item->get_latest_related_datetime() |
391 | 391 | : null; |
392 | 392 | $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
393 | 393 | ? $latest_related_datetime->ID() |
394 | 394 | : $DTT_ID; |
395 | - if ( ! empty( $DTT_ID ) |
|
395 | + if ( ! empty($DTT_ID) |
|
396 | 396 | && EE_Registry::instance()->CAP->current_user_can( |
397 | 397 | 'ee_read_checkins', |
398 | 398 | 'espresso_registrations_registration_checkins' |
399 | 399 | ) |
400 | 400 | ) { |
401 | 401 | $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
402 | - array( 'action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID ) |
|
402 | + array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID) |
|
403 | 403 | ); |
404 | 404 | // get the timestamps for this registration's checkins, related to the selected datetime |
405 | - $timestamps = $item->get_many_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
406 | - if( ! empty( $timestamps ) ) { |
|
405 | + $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
406 | + if ( ! empty($timestamps)) { |
|
407 | 407 | // get the last timestamp |
408 | - $last_timestamp = end( $timestamps ); |
|
408 | + $last_timestamp = end($timestamps); |
|
409 | 409 | // checked in or checked out? |
410 | - $checkin_status = $last_timestamp->get( 'CHK_in' ) |
|
411 | - ? esc_html__( 'Checked In', 'event_espresso' ) |
|
412 | - : esc_html__( 'Checked Out', 'event_espresso' ); |
|
410 | + $checkin_status = $last_timestamp->get('CHK_in') |
|
411 | + ? esc_html__('Checked In', 'event_espresso') |
|
412 | + : esc_html__('Checked Out', 'event_espresso'); |
|
413 | 413 | // get timestamp string |
414 | - $timestamp_string = $last_timestamp->get_datetime( 'CHK_timestamp' ); |
|
415 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__( |
|
414 | + $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
415 | + $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__( |
|
416 | 416 | 'View this registrant\'s check-ins/checkouts for the datetime', |
417 | 417 | 'event_espresso' |
418 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
418 | + ).'">'.$checkin_status.': '.$timestamp_string.'</a>'; |
|
419 | 419 | } |
420 | 420 | } |
421 | - return ( ! empty( $DTT_ID ) && ! empty( $timestamps ) ) |
|
422 | - ? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions, true ) ) |
|
421 | + return ( ! empty($DTT_ID) && ! empty($timestamps)) |
|
422 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
423 | 423 | : $name_link; |
424 | 424 | } |
425 | 425 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @param \EE_Registration $item |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function column_ATT_email( EE_Registration $item ) { |
|
432 | + public function column_ATT_email(EE_Registration $item) { |
|
433 | 433 | $attendee = $item->attendee(); |
434 | 434 | return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
435 | 435 | } |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | * @return bool|string |
442 | 442 | * @throws \EE_Error |
443 | 443 | */ |
444 | - public function column_Event( EE_Registration $item ) { |
|
444 | + public function column_Event(EE_Registration $item) { |
|
445 | 445 | try { |
446 | 446 | $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
447 | 447 | $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
448 | - array( 'action' => 'event_registrations', 'event_id' => $event->ID() ), |
|
448 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
449 | 449 | REG_ADMIN_URL |
450 | 450 | ); |
451 | 451 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
452 | 452 | 'ee_read_checkins', |
453 | 453 | 'espresso_registrations_registration_checkins' |
454 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__( |
|
454 | + ) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__( |
|
455 | 455 | 'View Checkins for this Event', |
456 | 456 | 'event_espresso' |
457 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
458 | - } catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) { |
|
459 | - $event_label = esc_html__( 'Unknown', 'event_espresso' ); |
|
457 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
458 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
459 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
460 | 460 | } |
461 | 461 | return $event_label; |
462 | 462 | } |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | * @param \EE_Registration $item |
468 | 468 | * @return mixed|string|void |
469 | 469 | */ |
470 | - public function column_PRC_name( EE_Registration $item ) { |
|
471 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" ); |
|
470 | + public function column_PRC_name(EE_Registration $item) { |
|
471 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso"); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | * @param \EE_Registration $item |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - public function column__REG_final_price( EE_Registration $item ) { |
|
483 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
482 | + public function column__REG_final_price(EE_Registration $item) { |
|
483 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -492,13 +492,13 @@ discard block |
||
492 | 492 | * @return string |
493 | 493 | * @throws \EE_Error |
494 | 494 | */ |
495 | - public function column_TXN_paid( EE_Registration $item ) { |
|
496 | - if ( $item->count() === 1 ) { |
|
497 | - if ( $item->transaction()->paid() >= $item->transaction()->total() ) { |
|
495 | + public function column_TXN_paid(EE_Registration $item) { |
|
496 | + if ($item->count() === 1) { |
|
497 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
498 | 498 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
499 | 499 | } else { |
500 | 500 | $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
501 | - array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ), |
|
501 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
502 | 502 | TXN_ADMIN_URL |
503 | 503 | ); |
504 | 504 | return EE_Registry::instance()->CAP->current_user_can( |
@@ -511,13 +511,13 @@ discard block |
||
511 | 511 | . '" href="' |
512 | 512 | . $view_txn_lnk_url |
513 | 513 | . '" title="' |
514 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
514 | + . esc_attr__('View Transaction', 'event_espresso') |
|
515 | 515 | . '"> |
516 | 516 | ' |
517 | 517 | . $item->transaction()->pretty_paid() |
518 | 518 | . ' |
519 | 519 | </a> |
520 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
520 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
521 | 521 | } |
522 | 522 | } else { |
523 | 523 | return '<span class="reg-pad-rght"></span>'; |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | * @return string |
534 | 534 | * @throws \EE_Error |
535 | 535 | */ |
536 | - public function column_TXN_total( EE_Registration $item ) { |
|
536 | + public function column_TXN_total(EE_Registration $item) { |
|
537 | 537 | $txn = $item->transaction(); |
538 | - $view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL ); |
|
539 | - if ( $item->get( 'REG_count' ) === 1 ) { |
|
538 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
539 | + if ($item->get('REG_count') === 1) { |
|
540 | 540 | $line_total_obj = $txn->total_line_item(); |
541 | 541 | $txn_total = $line_total_obj instanceof EE_Line_Item |
542 | - ? $line_total_obj->get_pretty( 'LIN_total' ) |
|
542 | + ? $line_total_obj->get_pretty('LIN_total') |
|
543 | 543 | : __( |
544 | 544 | 'View Transaction', |
545 | 545 | 'event_espresso' |
@@ -550,10 +550,10 @@ discard block |
||
550 | 550 | ) ? '<a href="' |
551 | 551 | . $view_txn_url |
552 | 552 | . '" title="' |
553 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
553 | + . esc_attr__('View Transaction', 'event_espresso') |
|
554 | 554 | . '"><span class="reg-pad-rght">' |
555 | 555 | . $txn_total |
556 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
556 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
557 | 557 | } else { |
558 | 558 | return '<span class="reg-pad-rght"></span>'; |
559 | 559 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -32,224 +32,224 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * This is used to hold the reports template data which is setup early in the request. |
|
37 | - * @type array |
|
38 | - */ |
|
39 | - protected $_reports_template_data = array(); |
|
40 | - |
|
41 | - /** |
|
42 | - * @Constructor |
|
43 | - * @access public |
|
44 | - * |
|
45 | - * @param bool $routing |
|
46 | - * |
|
47 | - * @return \Extend_Transactions_Admin_Page |
|
48 | - */ |
|
49 | - public function __construct($routing = true) |
|
50 | - { |
|
51 | - parent::__construct($routing); |
|
52 | - define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
53 | - define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
54 | - define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * _extend_page_config |
|
60 | - * |
|
61 | - * @access protected |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - protected function _extend_page_config() |
|
65 | - { |
|
66 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
67 | - |
|
68 | - $new_page_routes = array( |
|
69 | - 'reports' => array( |
|
70 | - 'func' => '_transaction_reports', |
|
71 | - 'capability' => 'ee_read_transactions' |
|
72 | - ) |
|
73 | - ); |
|
74 | - |
|
75 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
76 | - |
|
77 | - $new_page_config = array( |
|
78 | - 'reports' => array( |
|
79 | - 'nav' => array( |
|
80 | - 'label' => __('Reports', 'event_espresso'), |
|
81 | - 'order' => 20 |
|
82 | - ), |
|
83 | - 'help_tabs' => array( |
|
84 | - 'transactions_reports_help_tab' => array( |
|
85 | - 'title' => __('Transaction Reports', 'event_espresso'), |
|
86 | - 'filename' => 'transactions_reports' |
|
87 | - ) |
|
88 | - ), |
|
89 | - /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/ |
|
90 | - 'require_nonce' => false |
|
91 | - ) |
|
92 | - ); |
|
93 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * load_scripts_styles_reports |
|
99 | - * |
|
100 | - * @access public |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - public function load_scripts_styles_reports() |
|
104 | - { |
|
105 | - wp_register_script( |
|
106 | - 'ee-txn-reports-js', |
|
107 | - TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
108 | - array('google-charts'), |
|
109 | - EVENT_ESPRESSO_VERSION, |
|
110 | - true |
|
111 | - ); |
|
112 | - wp_enqueue_script('ee-txn-reports-js'); |
|
113 | - $this->_transaction_reports_js_setup(); |
|
114 | - EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
120 | - * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
121 | - */ |
|
122 | - protected function _transaction_reports_js_setup() |
|
123 | - { |
|
124 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
125 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * _transaction_reports |
|
131 | - * generates Business Reports regarding Transactions |
|
132 | - * |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function _transaction_reports() |
|
136 | - { |
|
137 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
138 | - $this->_admin_page_title = __('Transactions', 'event_espresso'); |
|
139 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
140 | - $this->_reports_template_data, true); |
|
141 | - |
|
142 | - // the final template wrapper |
|
143 | - $this->display_admin_page_with_no_sidebar(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * _revenue_per_day_report |
|
149 | - * generates Business Report showing Total Revenue per Day. |
|
150 | - * |
|
151 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - private function _revenue_per_day_report($period = '-1 month') |
|
156 | - { |
|
157 | - |
|
158 | - $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
159 | - |
|
160 | - $TXN = EEM_Transaction::instance(); |
|
161 | - |
|
162 | - $results = $TXN->get_revenue_per_day_report($period); |
|
163 | - $results = (array)$results; |
|
164 | - $revenue = array(); |
|
165 | - $subtitle = ''; |
|
166 | - |
|
167 | - if ($results) { |
|
168 | - $revenue[] = array( |
|
169 | - __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
170 | - __('Total Revenue', 'event_espresso') |
|
171 | - ); |
|
172 | - foreach ($results as $result) { |
|
173 | - $revenue[] = array($result->txnDate, (float)$result->revenue); |
|
174 | - } |
|
175 | - |
|
176 | - //setup the date range. |
|
177 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
178 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
179 | - $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
180 | - $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
181 | - } |
|
182 | - |
|
183 | - $report_title = esc_html__('Total Revenue per Day', 'event_espresso'); |
|
184 | - |
|
185 | - $report_params = array( |
|
186 | - 'title' => $report_title, |
|
187 | - 'subtitle' => $subtitle, |
|
188 | - 'id' => $report_ID, |
|
189 | - 'revenue' => $revenue, |
|
190 | - 'noResults' => empty($revenue) || count($revenue) === 1, |
|
191 | - 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
192 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
193 | - ); |
|
194 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
195 | - |
|
196 | - return $report_ID; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * _revenue_per_event_report |
|
202 | - * generates Business Report showing total revenue per event. |
|
203 | - * |
|
204 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
205 | - * |
|
206 | - * @return int |
|
207 | - */ |
|
208 | - private function _revenue_per_event_report($period = '-1 month') |
|
209 | - { |
|
210 | - |
|
211 | - $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
212 | - |
|
213 | - $TXN = EEM_Transaction::instance(); |
|
214 | - $results = $TXN->get_revenue_per_event_report($period); |
|
215 | - $results = (array)$results; |
|
216 | - $revenue = array(); |
|
217 | - $subtitle = ''; |
|
218 | - |
|
219 | - if ($results) { |
|
220 | - $revenue[] = array( |
|
221 | - __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
222 | - __('Total Revenue', 'event_espresso') |
|
223 | - ); |
|
224 | - foreach ($results as $result) { |
|
225 | - if ($result->revenue > 1) { |
|
226 | - $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
227 | - $event_name = wp_trim_words($event_name, 5, '...'); |
|
228 | - $revenue[] = array($event_name, (float)$result->revenue); |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - //setup the date range. |
|
233 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
234 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
235 | - $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
236 | - $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
237 | - } |
|
238 | - |
|
239 | - $report_title = esc_html__('Total Revenue per Event', 'event_espresso'); |
|
240 | - |
|
241 | - $report_params = array( |
|
242 | - 'title' => $report_title, |
|
243 | - 'subtitle' => $subtitle, |
|
244 | - 'id' => $report_ID, |
|
245 | - 'revenue' => $revenue, |
|
246 | - 'noResults' => empty($revenue), |
|
247 | - 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
248 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
249 | - ); |
|
250 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
251 | - |
|
252 | - return $report_ID; |
|
253 | - } |
|
35 | + /** |
|
36 | + * This is used to hold the reports template data which is setup early in the request. |
|
37 | + * @type array |
|
38 | + */ |
|
39 | + protected $_reports_template_data = array(); |
|
40 | + |
|
41 | + /** |
|
42 | + * @Constructor |
|
43 | + * @access public |
|
44 | + * |
|
45 | + * @param bool $routing |
|
46 | + * |
|
47 | + * @return \Extend_Transactions_Admin_Page |
|
48 | + */ |
|
49 | + public function __construct($routing = true) |
|
50 | + { |
|
51 | + parent::__construct($routing); |
|
52 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
53 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
54 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * _extend_page_config |
|
60 | + * |
|
61 | + * @access protected |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + protected function _extend_page_config() |
|
65 | + { |
|
66 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
67 | + |
|
68 | + $new_page_routes = array( |
|
69 | + 'reports' => array( |
|
70 | + 'func' => '_transaction_reports', |
|
71 | + 'capability' => 'ee_read_transactions' |
|
72 | + ) |
|
73 | + ); |
|
74 | + |
|
75 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
76 | + |
|
77 | + $new_page_config = array( |
|
78 | + 'reports' => array( |
|
79 | + 'nav' => array( |
|
80 | + 'label' => __('Reports', 'event_espresso'), |
|
81 | + 'order' => 20 |
|
82 | + ), |
|
83 | + 'help_tabs' => array( |
|
84 | + 'transactions_reports_help_tab' => array( |
|
85 | + 'title' => __('Transaction Reports', 'event_espresso'), |
|
86 | + 'filename' => 'transactions_reports' |
|
87 | + ) |
|
88 | + ), |
|
89 | + /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/ |
|
90 | + 'require_nonce' => false |
|
91 | + ) |
|
92 | + ); |
|
93 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * load_scripts_styles_reports |
|
99 | + * |
|
100 | + * @access public |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + public function load_scripts_styles_reports() |
|
104 | + { |
|
105 | + wp_register_script( |
|
106 | + 'ee-txn-reports-js', |
|
107 | + TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
108 | + array('google-charts'), |
|
109 | + EVENT_ESPRESSO_VERSION, |
|
110 | + true |
|
111 | + ); |
|
112 | + wp_enqueue_script('ee-txn-reports-js'); |
|
113 | + $this->_transaction_reports_js_setup(); |
|
114 | + EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
120 | + * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
121 | + */ |
|
122 | + protected function _transaction_reports_js_setup() |
|
123 | + { |
|
124 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
125 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * _transaction_reports |
|
131 | + * generates Business Reports regarding Transactions |
|
132 | + * |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function _transaction_reports() |
|
136 | + { |
|
137 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
138 | + $this->_admin_page_title = __('Transactions', 'event_espresso'); |
|
139 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
140 | + $this->_reports_template_data, true); |
|
141 | + |
|
142 | + // the final template wrapper |
|
143 | + $this->display_admin_page_with_no_sidebar(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * _revenue_per_day_report |
|
149 | + * generates Business Report showing Total Revenue per Day. |
|
150 | + * |
|
151 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + private function _revenue_per_day_report($period = '-1 month') |
|
156 | + { |
|
157 | + |
|
158 | + $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
159 | + |
|
160 | + $TXN = EEM_Transaction::instance(); |
|
161 | + |
|
162 | + $results = $TXN->get_revenue_per_day_report($period); |
|
163 | + $results = (array)$results; |
|
164 | + $revenue = array(); |
|
165 | + $subtitle = ''; |
|
166 | + |
|
167 | + if ($results) { |
|
168 | + $revenue[] = array( |
|
169 | + __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
170 | + __('Total Revenue', 'event_espresso') |
|
171 | + ); |
|
172 | + foreach ($results as $result) { |
|
173 | + $revenue[] = array($result->txnDate, (float)$result->revenue); |
|
174 | + } |
|
175 | + |
|
176 | + //setup the date range. |
|
177 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
178 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
179 | + $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
180 | + $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
181 | + } |
|
182 | + |
|
183 | + $report_title = esc_html__('Total Revenue per Day', 'event_espresso'); |
|
184 | + |
|
185 | + $report_params = array( |
|
186 | + 'title' => $report_title, |
|
187 | + 'subtitle' => $subtitle, |
|
188 | + 'id' => $report_ID, |
|
189 | + 'revenue' => $revenue, |
|
190 | + 'noResults' => empty($revenue) || count($revenue) === 1, |
|
191 | + 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
192 | + '<h2>' . $report_title . '</h2><p>', '</p>') |
|
193 | + ); |
|
194 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
195 | + |
|
196 | + return $report_ID; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * _revenue_per_event_report |
|
202 | + * generates Business Report showing total revenue per event. |
|
203 | + * |
|
204 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
205 | + * |
|
206 | + * @return int |
|
207 | + */ |
|
208 | + private function _revenue_per_event_report($period = '-1 month') |
|
209 | + { |
|
210 | + |
|
211 | + $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
212 | + |
|
213 | + $TXN = EEM_Transaction::instance(); |
|
214 | + $results = $TXN->get_revenue_per_event_report($period); |
|
215 | + $results = (array)$results; |
|
216 | + $revenue = array(); |
|
217 | + $subtitle = ''; |
|
218 | + |
|
219 | + if ($results) { |
|
220 | + $revenue[] = array( |
|
221 | + __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
222 | + __('Total Revenue', 'event_espresso') |
|
223 | + ); |
|
224 | + foreach ($results as $result) { |
|
225 | + if ($result->revenue > 1) { |
|
226 | + $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
227 | + $event_name = wp_trim_words($event_name, 5, '...'); |
|
228 | + $revenue[] = array($event_name, (float)$result->revenue); |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + //setup the date range. |
|
233 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
234 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
235 | + $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
236 | + $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
237 | + } |
|
238 | + |
|
239 | + $report_title = esc_html__('Total Revenue per Event', 'event_espresso'); |
|
240 | + |
|
241 | + $report_params = array( |
|
242 | + 'title' => $report_title, |
|
243 | + 'subtitle' => $subtitle, |
|
244 | + 'id' => $report_ID, |
|
245 | + 'revenue' => $revenue, |
|
246 | + 'noResults' => empty($revenue), |
|
247 | + 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
248 | + '<h2>' . $report_title . '</h2><p>', '</p>') |
|
249 | + ); |
|
250 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
251 | + |
|
252 | + return $report_ID; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | public function __construct($routing = true) |
50 | 50 | { |
51 | 51 | parent::__construct($routing); |
52 | - define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
53 | - define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
54 | - define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
52 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/'); |
|
53 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/'); |
|
54 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function _extend_page_config() |
65 | 65 | { |
66 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
66 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions'; |
|
67 | 67 | |
68 | 68 | $new_page_routes = array( |
69 | 69 | 'reports' => array( |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | wp_register_script( |
106 | 106 | 'ee-txn-reports-js', |
107 | - TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
107 | + TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js', |
|
108 | 108 | array('google-charts'), |
109 | 109 | EVENT_ESPRESSO_VERSION, |
110 | 110 | true |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function _transaction_reports() |
136 | 136 | { |
137 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
137 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
138 | 138 | $this->_admin_page_title = __('Transactions', 'event_espresso'); |
139 | 139 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
140 | 140 | $this->_reports_template_data, true); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $TXN = EEM_Transaction::instance(); |
161 | 161 | |
162 | 162 | $results = $TXN->get_revenue_per_day_report($period); |
163 | - $results = (array)$results; |
|
163 | + $results = (array) $results; |
|
164 | 164 | $revenue = array(); |
165 | 165 | $subtitle = ''; |
166 | 166 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | __('Total Revenue', 'event_espresso') |
171 | 171 | ); |
172 | 172 | foreach ($results as $result) { |
173 | - $revenue[] = array($result->txnDate, (float)$result->revenue); |
|
173 | + $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | //setup the date range. |
177 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
177 | + $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
178 | 178 | $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
179 | 179 | $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
180 | 180 | $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'revenue' => $revenue, |
190 | 190 | 'noResults' => empty($revenue) || count($revenue) === 1, |
191 | 191 | 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
192 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
192 | + '<h2>'.$report_title.'</h2><p>', '</p>') |
|
193 | 193 | ); |
194 | 194 | wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
195 | 195 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $TXN = EEM_Transaction::instance(); |
214 | 214 | $results = $TXN->get_revenue_per_event_report($period); |
215 | - $results = (array)$results; |
|
215 | + $results = (array) $results; |
|
216 | 216 | $revenue = array(); |
217 | 217 | $subtitle = ''; |
218 | 218 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | if ($result->revenue > 1) { |
226 | 226 | $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
227 | 227 | $event_name = wp_trim_words($event_name, 5, '...'); |
228 | - $revenue[] = array($event_name, (float)$result->revenue); |
|
228 | + $revenue[] = array($event_name, (float) $result->revenue); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | //setup the date range. |
233 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
233 | + $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
234 | 234 | $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
235 | 235 | $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
236 | 236 | $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'revenue' => $revenue, |
246 | 246 | 'noResults' => empty($revenue), |
247 | 247 | 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
248 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
248 | + '<h2>'.$report_title.'</h2><p>', '</p>') |
|
249 | 249 | ); |
250 | 250 | wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
251 | 251 |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | //If there is no event objecdt by now then get out. |
167 | - if (! $this->_event instanceof EE_Event) { |
|
167 | + if ( ! $this->_event instanceof EE_Event) { |
|
168 | 168 | return ''; |
169 | 169 | } |
170 | 170 | |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | break; |
191 | 191 | |
192 | 192 | case 'image': |
193 | - return '<img src="' . $venue->feature_image_url(array(200, 200,)) |
|
194 | - . '" alt="' . sprintf( |
|
193 | + return '<img src="'.$venue->feature_image_url(array(200, 200,)) |
|
194 | + . '" alt="'.sprintf( |
|
195 | 195 | esc_attr__('%s Feature Image', 'event_espresso'), |
196 | 196 | $venue->get('VNU_name') |
197 | - ) . '" />'; |
|
197 | + ).'" />'; |
|
198 | 198 | break; |
199 | 199 | |
200 | 200 | case 'phone': |
@@ -16,257 +16,257 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Will hold the EE_Event if available |
|
21 | - * |
|
22 | - * @var EE_Event |
|
23 | - */ |
|
24 | - protected $_event; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * Initialize properties |
|
29 | - */ |
|
30 | - protected function _init_props() |
|
31 | - { |
|
32 | - $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
33 | - $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
34 | - $this->_shortcodes = array( |
|
35 | - '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
36 | - '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
37 | - '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
38 | - '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
39 | - '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
40 | - '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
41 | - '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
42 | - '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
43 | - '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
44 | - '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
45 | - '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
46 | - 'This just outputs the venue address in a semantic address format.', |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
50 | - '[GOOGLE_MAP_URL]' => esc_html__( |
|
51 | - 'URL for the google map associated with the venue.', |
|
52 | - 'event_espresso' |
|
53 | - ), |
|
54 | - '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
55 | - '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Parse incoming shortcode |
|
62 | - * @param string $shortcode |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - protected function _parser($shortcode) |
|
66 | - { |
|
67 | - |
|
68 | - switch ($shortcode) { |
|
69 | - case '[VENUE_TITLE]': |
|
70 | - return $this->_venue('title'); |
|
71 | - break; |
|
72 | - |
|
73 | - case '[VENUE_DESCRIPTION]': |
|
74 | - return $this->_venue('description'); |
|
75 | - break; |
|
76 | - |
|
77 | - case '[VENUE_URL]': |
|
78 | - return $this->_venue('url'); |
|
79 | - break; |
|
80 | - |
|
81 | - case '[VENUE_IMAGE]': |
|
82 | - return $this->_venue('image'); |
|
83 | - break; |
|
84 | - |
|
85 | - case '[VENUE_PHONE]': |
|
86 | - return $this->_venue('phone'); |
|
87 | - break; |
|
88 | - |
|
89 | - case '[VENUE_ADDRESS]': |
|
90 | - return $this->_venue('address'); |
|
91 | - break; |
|
92 | - |
|
93 | - case '[VENUE_ADDRESS2]': |
|
94 | - return $this->_venue('address2'); |
|
95 | - break; |
|
96 | - |
|
97 | - case '[VENUE_CITY]': |
|
98 | - return $this->_venue('city'); |
|
99 | - break; |
|
100 | - |
|
101 | - case '[VENUE_COUNTRY]': |
|
102 | - return $this->_venue('country'); |
|
103 | - break; |
|
104 | - |
|
105 | - case '[VENUE_STATE]': |
|
106 | - return $this->_venue('state'); |
|
107 | - break; |
|
108 | - |
|
109 | - case '[VENUE_ZIP]': |
|
110 | - return $this->_venue('zip'); |
|
111 | - break; |
|
112 | - |
|
113 | - case '[VENUE_FORMATTED_ADDRESS]': |
|
114 | - return $this->_venue('formatted_address'); |
|
115 | - break; |
|
116 | - |
|
117 | - case '[GOOGLE_MAP_URL]': |
|
118 | - return $this->_venue('gmap_url'); |
|
119 | - break; |
|
120 | - |
|
121 | - case '[GOOGLE_MAP_LINK]': |
|
122 | - return $this->_venue('gmap_link'); |
|
123 | - break; |
|
124 | - |
|
125 | - case '[GOOGLE_MAP_IMAGE]': |
|
126 | - return $this->_venue('gmap_link_img'); |
|
127 | - break; |
|
128 | - |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * This retrieves the specified venue information |
|
135 | - * |
|
136 | - * @param string $field What Venue field to retrieve |
|
137 | - * @return string What was retrieved! |
|
138 | - * @throws EE_Error |
|
139 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
140 | - */ |
|
141 | - private function _venue($field) |
|
142 | - { |
|
143 | - //we need the EE_Event object to get the venue. |
|
144 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
145 | - |
|
146 | - //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
|
147 | - if (empty($this->_event)) { |
|
148 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
149 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
150 | - |
|
151 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : null; |
|
152 | - |
|
153 | - //if still empty do we have a ticket data item? |
|
154 | - $this->_event = empty($this->_event) |
|
155 | - && $this->_data instanceof EE_Ticket |
|
156 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
157 | - ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
158 | - : $this->_event; |
|
159 | - |
|
160 | - //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee and use that. |
|
161 | - $event = $aee instanceof EE_Messages_Addressee ? reset($aee->events) : array(); |
|
162 | - $this->_event = empty($this->_event) && ! empty($events) ? $event : $this->_event; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - //If there is no event objecdt by now then get out. |
|
167 | - if (! $this->_event instanceof EE_Event) { |
|
168 | - return ''; |
|
169 | - } |
|
170 | - |
|
171 | - /** @var EE_Venue $venue */ |
|
172 | - $venue = $this->_event->get_first_related('Venue'); |
|
173 | - |
|
174 | - if (empty($venue)) { |
|
175 | - return ''; |
|
176 | - } //no venue so get out. |
|
177 | - |
|
178 | - switch ($field) { |
|
179 | - case 'title': |
|
180 | - return $venue->get('VNU_name'); |
|
181 | - break; |
|
182 | - |
|
183 | - case 'description': |
|
184 | - return $venue->get('VNU_desc'); |
|
185 | - break; |
|
186 | - |
|
187 | - case 'url': |
|
188 | - $url = $venue->get('VNU_url'); |
|
189 | - return empty($url) ? $venue->get_permalink() : $url; |
|
190 | - break; |
|
191 | - |
|
192 | - case 'image': |
|
193 | - return '<img src="' . $venue->feature_image_url(array(200, 200,)) |
|
194 | - . '" alt="' . sprintf( |
|
195 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
196 | - $venue->get('VNU_name') |
|
197 | - ) . '" />'; |
|
198 | - break; |
|
199 | - |
|
200 | - case 'phone': |
|
201 | - return $venue->get('VNU_phone'); |
|
202 | - break; |
|
203 | - |
|
204 | - case 'address': |
|
205 | - return $venue->get('VNU_address'); |
|
206 | - break; |
|
207 | - |
|
208 | - case 'address2': |
|
209 | - return $venue->get('VNU_address2'); |
|
210 | - break; |
|
211 | - |
|
212 | - case 'city': |
|
213 | - return $venue->get('VNU_city'); |
|
214 | - break; |
|
215 | - |
|
216 | - case 'state': |
|
217 | - $state = $venue->state_obj(); |
|
218 | - return is_object($state) ? $state->get('STA_name') : ''; |
|
219 | - break; |
|
220 | - |
|
221 | - case 'country': |
|
222 | - $country = $venue->country_obj(); |
|
223 | - return is_object($country) ? $country->get('CNT_name') : ''; |
|
224 | - break; |
|
225 | - |
|
226 | - case 'zip': |
|
227 | - return $venue->get('VNU_zip'); |
|
228 | - break; |
|
229 | - |
|
230 | - case 'formatted_address': |
|
231 | - return EEH_Address::format($venue); |
|
232 | - break; |
|
233 | - |
|
234 | - case 'gmap_link': |
|
235 | - case 'gmap_url': |
|
236 | - case 'gmap_link_img': |
|
237 | - $atts = $this->get_map_attributes($venue, $field); |
|
238 | - return EEH_Maps::google_map_link($atts); |
|
239 | - break; |
|
240 | - } |
|
241 | - return ''; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Generates the attributes for retrieving a google_map artifact. |
|
247 | - * @param EE_Venue $venue |
|
248 | - * @param string $field |
|
249 | - * @return array |
|
250 | - * @throws EE_Error |
|
251 | - */ |
|
252 | - protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
253 | - { |
|
254 | - $state = $venue->state_obj(); |
|
255 | - $country = $venue->country_obj(); |
|
256 | - $atts = array( |
|
257 | - 'id' => $venue->ID(), |
|
258 | - 'address' => $venue->get('VNU_address'), |
|
259 | - 'city' => $venue->get('VNU_city'), |
|
260 | - 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
261 | - 'zip' => $venue->get('VNU_zip'), |
|
262 | - 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
263 | - 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
264 | - 'map_w' => 200, |
|
265 | - 'map_h' => 200, |
|
266 | - ); |
|
267 | - if ($field === 'gmap_url') { |
|
268 | - $atts['type'] = 'url_only'; |
|
269 | - } |
|
270 | - return $atts; |
|
271 | - } |
|
19 | + /** |
|
20 | + * Will hold the EE_Event if available |
|
21 | + * |
|
22 | + * @var EE_Event |
|
23 | + */ |
|
24 | + protected $_event; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * Initialize properties |
|
29 | + */ |
|
30 | + protected function _init_props() |
|
31 | + { |
|
32 | + $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
33 | + $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
34 | + $this->_shortcodes = array( |
|
35 | + '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
36 | + '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
37 | + '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
38 | + '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
39 | + '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
40 | + '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
41 | + '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
42 | + '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
43 | + '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
44 | + '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
45 | + '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
46 | + 'This just outputs the venue address in a semantic address format.', |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
50 | + '[GOOGLE_MAP_URL]' => esc_html__( |
|
51 | + 'URL for the google map associated with the venue.', |
|
52 | + 'event_espresso' |
|
53 | + ), |
|
54 | + '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
55 | + '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Parse incoming shortcode |
|
62 | + * @param string $shortcode |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + protected function _parser($shortcode) |
|
66 | + { |
|
67 | + |
|
68 | + switch ($shortcode) { |
|
69 | + case '[VENUE_TITLE]': |
|
70 | + return $this->_venue('title'); |
|
71 | + break; |
|
72 | + |
|
73 | + case '[VENUE_DESCRIPTION]': |
|
74 | + return $this->_venue('description'); |
|
75 | + break; |
|
76 | + |
|
77 | + case '[VENUE_URL]': |
|
78 | + return $this->_venue('url'); |
|
79 | + break; |
|
80 | + |
|
81 | + case '[VENUE_IMAGE]': |
|
82 | + return $this->_venue('image'); |
|
83 | + break; |
|
84 | + |
|
85 | + case '[VENUE_PHONE]': |
|
86 | + return $this->_venue('phone'); |
|
87 | + break; |
|
88 | + |
|
89 | + case '[VENUE_ADDRESS]': |
|
90 | + return $this->_venue('address'); |
|
91 | + break; |
|
92 | + |
|
93 | + case '[VENUE_ADDRESS2]': |
|
94 | + return $this->_venue('address2'); |
|
95 | + break; |
|
96 | + |
|
97 | + case '[VENUE_CITY]': |
|
98 | + return $this->_venue('city'); |
|
99 | + break; |
|
100 | + |
|
101 | + case '[VENUE_COUNTRY]': |
|
102 | + return $this->_venue('country'); |
|
103 | + break; |
|
104 | + |
|
105 | + case '[VENUE_STATE]': |
|
106 | + return $this->_venue('state'); |
|
107 | + break; |
|
108 | + |
|
109 | + case '[VENUE_ZIP]': |
|
110 | + return $this->_venue('zip'); |
|
111 | + break; |
|
112 | + |
|
113 | + case '[VENUE_FORMATTED_ADDRESS]': |
|
114 | + return $this->_venue('formatted_address'); |
|
115 | + break; |
|
116 | + |
|
117 | + case '[GOOGLE_MAP_URL]': |
|
118 | + return $this->_venue('gmap_url'); |
|
119 | + break; |
|
120 | + |
|
121 | + case '[GOOGLE_MAP_LINK]': |
|
122 | + return $this->_venue('gmap_link'); |
|
123 | + break; |
|
124 | + |
|
125 | + case '[GOOGLE_MAP_IMAGE]': |
|
126 | + return $this->_venue('gmap_link_img'); |
|
127 | + break; |
|
128 | + |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * This retrieves the specified venue information |
|
135 | + * |
|
136 | + * @param string $field What Venue field to retrieve |
|
137 | + * @return string What was retrieved! |
|
138 | + * @throws EE_Error |
|
139 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
140 | + */ |
|
141 | + private function _venue($field) |
|
142 | + { |
|
143 | + //we need the EE_Event object to get the venue. |
|
144 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
145 | + |
|
146 | + //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
|
147 | + if (empty($this->_event)) { |
|
148 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
149 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
150 | + |
|
151 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : null; |
|
152 | + |
|
153 | + //if still empty do we have a ticket data item? |
|
154 | + $this->_event = empty($this->_event) |
|
155 | + && $this->_data instanceof EE_Ticket |
|
156 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
157 | + ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
158 | + : $this->_event; |
|
159 | + |
|
160 | + //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee and use that. |
|
161 | + $event = $aee instanceof EE_Messages_Addressee ? reset($aee->events) : array(); |
|
162 | + $this->_event = empty($this->_event) && ! empty($events) ? $event : $this->_event; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + //If there is no event objecdt by now then get out. |
|
167 | + if (! $this->_event instanceof EE_Event) { |
|
168 | + return ''; |
|
169 | + } |
|
170 | + |
|
171 | + /** @var EE_Venue $venue */ |
|
172 | + $venue = $this->_event->get_first_related('Venue'); |
|
173 | + |
|
174 | + if (empty($venue)) { |
|
175 | + return ''; |
|
176 | + } //no venue so get out. |
|
177 | + |
|
178 | + switch ($field) { |
|
179 | + case 'title': |
|
180 | + return $venue->get('VNU_name'); |
|
181 | + break; |
|
182 | + |
|
183 | + case 'description': |
|
184 | + return $venue->get('VNU_desc'); |
|
185 | + break; |
|
186 | + |
|
187 | + case 'url': |
|
188 | + $url = $venue->get('VNU_url'); |
|
189 | + return empty($url) ? $venue->get_permalink() : $url; |
|
190 | + break; |
|
191 | + |
|
192 | + case 'image': |
|
193 | + return '<img src="' . $venue->feature_image_url(array(200, 200,)) |
|
194 | + . '" alt="' . sprintf( |
|
195 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
196 | + $venue->get('VNU_name') |
|
197 | + ) . '" />'; |
|
198 | + break; |
|
199 | + |
|
200 | + case 'phone': |
|
201 | + return $venue->get('VNU_phone'); |
|
202 | + break; |
|
203 | + |
|
204 | + case 'address': |
|
205 | + return $venue->get('VNU_address'); |
|
206 | + break; |
|
207 | + |
|
208 | + case 'address2': |
|
209 | + return $venue->get('VNU_address2'); |
|
210 | + break; |
|
211 | + |
|
212 | + case 'city': |
|
213 | + return $venue->get('VNU_city'); |
|
214 | + break; |
|
215 | + |
|
216 | + case 'state': |
|
217 | + $state = $venue->state_obj(); |
|
218 | + return is_object($state) ? $state->get('STA_name') : ''; |
|
219 | + break; |
|
220 | + |
|
221 | + case 'country': |
|
222 | + $country = $venue->country_obj(); |
|
223 | + return is_object($country) ? $country->get('CNT_name') : ''; |
|
224 | + break; |
|
225 | + |
|
226 | + case 'zip': |
|
227 | + return $venue->get('VNU_zip'); |
|
228 | + break; |
|
229 | + |
|
230 | + case 'formatted_address': |
|
231 | + return EEH_Address::format($venue); |
|
232 | + break; |
|
233 | + |
|
234 | + case 'gmap_link': |
|
235 | + case 'gmap_url': |
|
236 | + case 'gmap_link_img': |
|
237 | + $atts = $this->get_map_attributes($venue, $field); |
|
238 | + return EEH_Maps::google_map_link($atts); |
|
239 | + break; |
|
240 | + } |
|
241 | + return ''; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Generates the attributes for retrieving a google_map artifact. |
|
247 | + * @param EE_Venue $venue |
|
248 | + * @param string $field |
|
249 | + * @return array |
|
250 | + * @throws EE_Error |
|
251 | + */ |
|
252 | + protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
253 | + { |
|
254 | + $state = $venue->state_obj(); |
|
255 | + $country = $venue->country_obj(); |
|
256 | + $atts = array( |
|
257 | + 'id' => $venue->ID(), |
|
258 | + 'address' => $venue->get('VNU_address'), |
|
259 | + 'city' => $venue->get('VNU_city'), |
|
260 | + 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
261 | + 'zip' => $venue->get('VNU_zip'), |
|
262 | + 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
263 | + 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
264 | + 'map_w' => 200, |
|
265 | + 'map_h' => 200, |
|
266 | + ); |
|
267 | + if ($field === 'gmap_url') { |
|
268 | + $atts['type'] = 'url_only'; |
|
269 | + } |
|
270 | + return $atts; |
|
271 | + } |
|
272 | 272 | } |
@@ -14,176 +14,176 @@ |
||
14 | 14 | class EEH_Maps |
15 | 15 | { |
16 | 16 | |
17 | - // array of map settings |
|
18 | - public static $gmap_vars = array(); |
|
19 | - |
|
20 | - |
|
21 | - /** |
|
22 | - * google_map - creates a Google Map Link |
|
23 | - * |
|
24 | - * @param array $ee_gmaps_opts array of attributes required for the map link generation |
|
25 | - * @return string (link to map!) |
|
26 | - */ |
|
27 | - public static function google_map($ee_gmaps_opts) |
|
28 | - { |
|
29 | - |
|
30 | - $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
31 | - $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
32 | - $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
33 | - $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
34 | - $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
|
35 | - ? $ee_gmaps_opts['ee_map_nav_size'] |
|
36 | - : 'default'; |
|
37 | - $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
|
38 | - ? $ee_gmaps_opts['ee_map_type_control'] |
|
39 | - : 'default'; |
|
40 | - $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
|
41 | - |
|
42 | - if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
43 | - switch ($ee_gmaps_opts['ee_map_align']) { |
|
44 | - case "left": |
|
45 | - $map_align = 'ee-gmap-align-left left'; |
|
46 | - break; |
|
47 | - case "right": |
|
48 | - $map_align = 'ee-gmap-align-right right'; |
|
49 | - break; |
|
50 | - case "center": |
|
51 | - $map_align = 'ee-gmap-align-center center'; |
|
52 | - break; |
|
53 | - case "none": |
|
54 | - default: |
|
55 | - $map_align = 'ee-gmap-align-none'; |
|
56 | - } |
|
57 | - } else { |
|
58 | - $map_align = 'ee-gmap-align-none'; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - // Determine whether user has set a hardoded url to use and |
|
63 | - // if so display a Google static iframe map else run V3 api |
|
64 | - if ($static_url) { |
|
65 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
66 | - $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
67 | - . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
68 | - . ' frameborder="0" scrolling="no">'; |
|
69 | - $html .= '</iframe>'; |
|
70 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
71 | - $html .= '</div>'; |
|
72 | - return $html; |
|
73 | - |
|
74 | - } else { |
|
75 | - EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
76 | - 'map_ID' => $ee_gmaps_opts['map_ID'], |
|
77 | - 'ee_map_zoom' => $ee_map_zoom, |
|
78 | - 'ee_map_nav_display' => $ee_map_nav_display, |
|
79 | - 'ee_map_nav_size' => $ee_map_nav_size, |
|
80 | - 'ee_map_type_control' => $ee_map_type_control, |
|
81 | - 'location' => $ee_gmaps_opts['location'], |
|
82 | - ); |
|
83 | - |
|
84 | - $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
85 | - $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
86 | - . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
87 | - . ' style="' . $style . '"></div>' |
|
88 | - . '</div>'; |
|
89 | - |
|
90 | - wp_enqueue_script('gmap_api'); |
|
91 | - wp_enqueue_script('ee_gmap'); |
|
92 | - add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
93 | - |
|
94 | - return $html; |
|
95 | - } // end auto map or static url map check |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * enqueue_script |
|
101 | - * |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public static function footer_enqueue_script() |
|
105 | - { |
|
106 | - wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * registers scripts for maps |
|
112 | - */ |
|
113 | - public static function espresso_google_map_js() |
|
114 | - { |
|
115 | - $api_url = sprintf( |
|
116 | - "https://maps.googleapis.com/maps/api/js?key=%s", |
|
117 | - apply_filters( |
|
118 | - 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
119 | - EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
120 | - ) |
|
121 | - ); |
|
122 | - wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
|
123 | - wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * creates a Google Map Link |
|
128 | - * |
|
129 | - * @param array $atts array of attributes required for the map link generation |
|
130 | - * @return string (link to map!) |
|
131 | - */ |
|
132 | - public static function google_map_link($atts) |
|
133 | - { |
|
134 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | - extract($atts); |
|
136 | - /** @var string $address */ |
|
137 | - /** @var string $city */ |
|
138 | - /** @var string $state */ |
|
139 | - /** @var string $zip */ |
|
140 | - /** @var string $country */ |
|
141 | - $address = "{$address}"; |
|
142 | - $city = "{$city}"; |
|
143 | - $state = "{$state}"; |
|
144 | - $zip = "{$zip}"; |
|
145 | - $country = "{$country}"; |
|
146 | - $text = isset($text) ? "{$text}" : ""; |
|
147 | - $type = isset($type) ? "{$type}" : ""; |
|
148 | - $map_w = isset($map_w) ? "{$map_w}" : 400; |
|
149 | - $map_h = isset($map_h) ? "{$map_h}" : 400; |
|
150 | - $id = isset($id) ? $id : 'not_set'; |
|
151 | - $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
|
152 | - |
|
153 | - $address_string = ($address != '' ? $address : '') |
|
154 | - . ($city != '' ? ',' . $city : '') |
|
155 | - . ($state != '' ? ',' . $state : '') |
|
156 | - . ($zip != '' ? ',' . $zip : '') |
|
157 | - . ($country != '' ? ',' . $country : ''); |
|
158 | - |
|
159 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
160 | - |
|
161 | - switch ($type) { |
|
162 | - case 'text': |
|
163 | - default: |
|
164 | - $text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; |
|
165 | - break; |
|
166 | - |
|
167 | - case 'url_only': |
|
168 | - case 'url': |
|
169 | - $text = $google_map; |
|
170 | - break; |
|
171 | - |
|
172 | - case 'map': |
|
173 | - $scheme = is_ssl() ? 'https://' : 'http://'; |
|
174 | - |
|
175 | - $api_key = apply_filters( |
|
176 | - 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', |
|
177 | - EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
178 | - ); |
|
179 | - |
|
180 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
181 | - } |
|
182 | - |
|
183 | - return $type === 'url_only' |
|
184 | - ? $text |
|
185 | - : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
186 | - } |
|
17 | + // array of map settings |
|
18 | + public static $gmap_vars = array(); |
|
19 | + |
|
20 | + |
|
21 | + /** |
|
22 | + * google_map - creates a Google Map Link |
|
23 | + * |
|
24 | + * @param array $ee_gmaps_opts array of attributes required for the map link generation |
|
25 | + * @return string (link to map!) |
|
26 | + */ |
|
27 | + public static function google_map($ee_gmaps_opts) |
|
28 | + { |
|
29 | + |
|
30 | + $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
31 | + $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
32 | + $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
33 | + $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
34 | + $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
|
35 | + ? $ee_gmaps_opts['ee_map_nav_size'] |
|
36 | + : 'default'; |
|
37 | + $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
|
38 | + ? $ee_gmaps_opts['ee_map_type_control'] |
|
39 | + : 'default'; |
|
40 | + $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
|
41 | + |
|
42 | + if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
43 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
44 | + case "left": |
|
45 | + $map_align = 'ee-gmap-align-left left'; |
|
46 | + break; |
|
47 | + case "right": |
|
48 | + $map_align = 'ee-gmap-align-right right'; |
|
49 | + break; |
|
50 | + case "center": |
|
51 | + $map_align = 'ee-gmap-align-center center'; |
|
52 | + break; |
|
53 | + case "none": |
|
54 | + default: |
|
55 | + $map_align = 'ee-gmap-align-none'; |
|
56 | + } |
|
57 | + } else { |
|
58 | + $map_align = 'ee-gmap-align-none'; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + // Determine whether user has set a hardoded url to use and |
|
63 | + // if so display a Google static iframe map else run V3 api |
|
64 | + if ($static_url) { |
|
65 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
66 | + $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
67 | + . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
68 | + . ' frameborder="0" scrolling="no">'; |
|
69 | + $html .= '</iframe>'; |
|
70 | + $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
71 | + $html .= '</div>'; |
|
72 | + return $html; |
|
73 | + |
|
74 | + } else { |
|
75 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
76 | + 'map_ID' => $ee_gmaps_opts['map_ID'], |
|
77 | + 'ee_map_zoom' => $ee_map_zoom, |
|
78 | + 'ee_map_nav_display' => $ee_map_nav_display, |
|
79 | + 'ee_map_nav_size' => $ee_map_nav_size, |
|
80 | + 'ee_map_type_control' => $ee_map_type_control, |
|
81 | + 'location' => $ee_gmaps_opts['location'], |
|
82 | + ); |
|
83 | + |
|
84 | + $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
85 | + $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
86 | + . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
87 | + . ' style="' . $style . '"></div>' |
|
88 | + . '</div>'; |
|
89 | + |
|
90 | + wp_enqueue_script('gmap_api'); |
|
91 | + wp_enqueue_script('ee_gmap'); |
|
92 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
93 | + |
|
94 | + return $html; |
|
95 | + } // end auto map or static url map check |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * enqueue_script |
|
101 | + * |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public static function footer_enqueue_script() |
|
105 | + { |
|
106 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * registers scripts for maps |
|
112 | + */ |
|
113 | + public static function espresso_google_map_js() |
|
114 | + { |
|
115 | + $api_url = sprintf( |
|
116 | + "https://maps.googleapis.com/maps/api/js?key=%s", |
|
117 | + apply_filters( |
|
118 | + 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
119 | + EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
120 | + ) |
|
121 | + ); |
|
122 | + wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
|
123 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * creates a Google Map Link |
|
128 | + * |
|
129 | + * @param array $atts array of attributes required for the map link generation |
|
130 | + * @return string (link to map!) |
|
131 | + */ |
|
132 | + public static function google_map_link($atts) |
|
133 | + { |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | + extract($atts); |
|
136 | + /** @var string $address */ |
|
137 | + /** @var string $city */ |
|
138 | + /** @var string $state */ |
|
139 | + /** @var string $zip */ |
|
140 | + /** @var string $country */ |
|
141 | + $address = "{$address}"; |
|
142 | + $city = "{$city}"; |
|
143 | + $state = "{$state}"; |
|
144 | + $zip = "{$zip}"; |
|
145 | + $country = "{$country}"; |
|
146 | + $text = isset($text) ? "{$text}" : ""; |
|
147 | + $type = isset($type) ? "{$type}" : ""; |
|
148 | + $map_w = isset($map_w) ? "{$map_w}" : 400; |
|
149 | + $map_h = isset($map_h) ? "{$map_h}" : 400; |
|
150 | + $id = isset($id) ? $id : 'not_set'; |
|
151 | + $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
|
152 | + |
|
153 | + $address_string = ($address != '' ? $address : '') |
|
154 | + . ($city != '' ? ',' . $city : '') |
|
155 | + . ($state != '' ? ',' . $state : '') |
|
156 | + . ($zip != '' ? ',' . $zip : '') |
|
157 | + . ($country != '' ? ',' . $country : ''); |
|
158 | + |
|
159 | + $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
160 | + |
|
161 | + switch ($type) { |
|
162 | + case 'text': |
|
163 | + default: |
|
164 | + $text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; |
|
165 | + break; |
|
166 | + |
|
167 | + case 'url_only': |
|
168 | + case 'url': |
|
169 | + $text = $google_map; |
|
170 | + break; |
|
171 | + |
|
172 | + case 'map': |
|
173 | + $scheme = is_ssl() ? 'https://' : 'http://'; |
|
174 | + |
|
175 | + $api_key = apply_filters( |
|
176 | + 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', |
|
177 | + EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
178 | + ); |
|
179 | + |
|
180 | + return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
181 | + } |
|
182 | + |
|
183 | + return $type === 'url_only' |
|
184 | + ? $text |
|
185 | + : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
186 | + } |
|
187 | 187 | } |
188 | 188 | // End of file EEH_Maps.helper.php |
189 | 189 | // Location: /helpers/EEH_Maps.helper.php |
190 | 190 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | : 'default'; |
40 | 40 | $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
41 | 41 | |
42 | - if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
42 | + if ( ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
43 | 43 | switch ($ee_gmaps_opts['ee_map_align']) { |
44 | 44 | case "left": |
45 | 45 | $map_align = 'ee-gmap-align-left left'; |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | // Determine whether user has set a hardoded url to use and |
63 | 63 | // if so display a Google static iframe map else run V3 api |
64 | 64 | if ($static_url) { |
65 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
66 | - $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
67 | - . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
65 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
66 | + $html .= '<iframe src="'.$static_url.'&output=embed"' |
|
67 | + . ' style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"' |
|
68 | 68 | . ' frameborder="0" scrolling="no">'; |
69 | 69 | $html .= '</iframe>'; |
70 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
70 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
71 | 71 | $html .= '</div>'; |
72 | 72 | return $html; |
73 | 73 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | 'location' => $ee_gmaps_opts['location'], |
82 | 82 | ); |
83 | 83 | |
84 | - $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
85 | - $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
86 | - . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
87 | - . ' style="' . $style . '"></div>' |
|
84 | + $style = 'width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;'; |
|
85 | + $html = '<div class="ee-gmap-wrapper '.$map_align.'">' |
|
86 | + . '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'"' |
|
87 | + . ' style="'.$style.'"></div>' |
|
88 | 88 | . '</div>'; |
89 | 89 | |
90 | 90 | wp_enqueue_script('gmap_api'); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
123 | - wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
123 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
152 | 152 | |
153 | 153 | $address_string = ($address != '' ? $address : '') |
154 | - . ($city != '' ? ',' . $city : '') |
|
155 | - . ($state != '' ? ',' . $state : '') |
|
156 | - . ($zip != '' ? ',' . $zip : '') |
|
157 | - . ($country != '' ? ',' . $country : ''); |
|
154 | + . ($city != '' ? ','.$city : '') |
|
155 | + . ($state != '' ? ','.$state : '') |
|
156 | + . ($zip != '' ? ','.$zip : '') |
|
157 | + . ($country != '' ? ','.$country : ''); |
|
158 | 158 | |
159 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
159 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
160 | 160 | |
161 | 161 | switch ($type) { |
162 | 162 | case 'text': |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | EE_Registry::instance()->CFG->map_settings->google_map_api_key |
178 | 178 | ); |
179 | 179 | |
180 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
180 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false&key='.$api_key).'" /></a>'; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $type === 'url_only' |
184 | 184 | ? $text |
185 | - : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
185 | + : '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | // End of file EEH_Maps.helper.php |
@@ -44,77 +44,76 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $_image_url; |
46 | 46 | |
47 | - /** |
|
48 | - * gateway URL variable |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $_base_gateway_url = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * EEG_Paypal_Express constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->_currencies_supported = array( |
|
62 | - 'USD', |
|
63 | - 'AUD', |
|
64 | - 'BRL', |
|
65 | - 'CAD', |
|
66 | - 'CZK', |
|
67 | - 'DKK', |
|
68 | - 'EUR', |
|
69 | - 'HKD', |
|
70 | - 'HUF', |
|
71 | - 'ILS', |
|
72 | - 'JPY', |
|
73 | - 'MYR', |
|
74 | - 'MXN', |
|
75 | - 'NOK', |
|
76 | - 'NZD', |
|
77 | - 'PHP', |
|
78 | - 'PLN', |
|
79 | - 'GBP', |
|
80 | - 'RUB', |
|
81 | - 'SGD', |
|
82 | - 'SEK', |
|
83 | - 'CHF', |
|
84 | - 'TWD', |
|
85 | - 'THB', |
|
86 | - 'TRY' |
|
87 | - ); |
|
88 | - parent::__construct(); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
47 | + /** |
|
48 | + * gateway URL variable |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $_base_gateway_url = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * EEG_Paypal_Express constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->_currencies_supported = array( |
|
62 | + 'USD', |
|
63 | + 'AUD', |
|
64 | + 'BRL', |
|
65 | + 'CAD', |
|
66 | + 'CZK', |
|
67 | + 'DKK', |
|
68 | + 'EUR', |
|
69 | + 'HKD', |
|
70 | + 'HUF', |
|
71 | + 'ILS', |
|
72 | + 'JPY', |
|
73 | + 'MYR', |
|
74 | + 'MXN', |
|
75 | + 'NOK', |
|
76 | + 'NZD', |
|
77 | + 'PHP', |
|
78 | + 'PLN', |
|
79 | + 'GBP', |
|
80 | + 'RUB', |
|
81 | + 'SGD', |
|
82 | + 'SEK', |
|
83 | + 'CHF', |
|
84 | + 'TWD', |
|
85 | + 'THB', |
|
86 | + 'TRY' |
|
87 | + ); |
|
88 | + parent::__construct(); |
|
89 | + } |
|
90 | + |
|
95 | 91 | |
92 | + |
|
93 | + /** |
|
94 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
96 | 95 | * |
97 | 96 | *@param array $settings_array |
98 | 97 | */ |
99 | 98 | public function set_settings( $settings_array ) { |
100 | 99 | parent::set_settings($settings_array); |
101 | 100 | // Redirect URL. |
102 | - $this->_base_gateway_url = $this->_debug_mode |
|
103 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
104 | - : 'https://api-3t.paypal.com/nvp'; |
|
101 | + $this->_base_gateway_url = $this->_debug_mode |
|
102 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
103 | + : 'https://api-3t.paypal.com/nvp'; |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | |
108 | 107 | |
109 | - /** |
|
110 | - * @param EEI_Payment $payment |
|
111 | - * @param array $billing_info |
|
112 | - * @param string $return_url |
|
113 | - * @param string $notify_url |
|
114 | - * @param string $cancel_url |
|
115 | - * @return \EE_Payment|\EEI_Payment |
|
116 | - * @throws \EE_Error |
|
117 | - */ |
|
108 | + /** |
|
109 | + * @param EEI_Payment $payment |
|
110 | + * @param array $billing_info |
|
111 | + * @param string $return_url |
|
112 | + * @param string $notify_url |
|
113 | + * @param string $cancel_url |
|
114 | + * @return \EE_Payment|\EEI_Payment |
|
115 | + * @throws \EE_Error |
|
116 | + */ |
|
118 | 117 | public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
119 | 118 | if ( ! $payment instanceof EEI_Payment ) { |
120 | 119 | $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
@@ -202,9 +201,9 @@ discard block |
||
202 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 202 | // Item quantity. |
204 | 203 | $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
205 | - // Digital item is sold. |
|
206 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
207 | - $item_num++; |
|
204 | + // Digital item is sold. |
|
205 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
206 | + $item_num++; |
|
208 | 207 | } |
209 | 208 | } else { |
210 | 209 | // Just one Item. |
@@ -277,7 +276,6 @@ discard block |
||
277 | 276 | |
278 | 277 | |
279 | 278 | /** |
280 | - |
|
281 | 279 | * @param array $update_info { |
282 | 280 | * @type string $gateway_txn_id |
283 | 281 | * @type string status an EEMI_Payment status |
@@ -297,8 +295,8 @@ discard block |
||
297 | 295 | return $payment; |
298 | 296 | } |
299 | 297 | $primary_registrant = $transaction->primary_registration(); |
300 | - $payment_details = $payment->details(); |
|
301 | - // Check if we still have the token. |
|
298 | + $payment_details = $payment->details(); |
|
299 | + // Check if we still have the token. |
|
302 | 300 | if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
303 | 301 | $payment->set_status( $this->_pay_model->failed_status() ); |
304 | 302 | return $payment; |
@@ -407,35 +405,35 @@ discard block |
||
407 | 405 | */ |
408 | 406 | public function _ppExpress_check_response( $request_response ) { |
409 | 407 | if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
410 | - // If we got here then there was an error in this request. |
|
411 | - return array('status' => false, 'args' => $request_response); |
|
412 | - } |
|
413 | - $response_args = array(); |
|
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
415 | - if ( ! isset($response_args['ACK'])) { |
|
416 | - return array('status' => false, 'args' => $request_response); |
|
417 | - } |
|
418 | - if ( |
|
419 | - ( |
|
420 | - isset($response_args['PAYERID']) |
|
421 | - || isset($response_args['TOKEN']) |
|
422 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
423 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
424 | - ) |
|
425 | - && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
426 | - ) { |
|
427 | - // Response status OK, return response parameters for further processing. |
|
428 | - return array('status' => true, 'args' => $response_args); |
|
429 | - } |
|
430 | - $errors = $this->_get_errors($response_args); |
|
431 | - return array('status' => false, 'args' => $errors); |
|
408 | + // If we got here then there was an error in this request. |
|
409 | + return array('status' => false, 'args' => $request_response); |
|
410 | + } |
|
411 | + $response_args = array(); |
|
412 | + parse_str( urldecode($request_response['body']), $response_args ); |
|
413 | + if ( ! isset($response_args['ACK'])) { |
|
414 | + return array('status' => false, 'args' => $request_response); |
|
415 | + } |
|
416 | + if ( |
|
417 | + ( |
|
418 | + isset($response_args['PAYERID']) |
|
419 | + || isset($response_args['TOKEN']) |
|
420 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
421 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
422 | + ) |
|
423 | + && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
424 | + ) { |
|
425 | + // Response status OK, return response parameters for further processing. |
|
426 | + return array('status' => true, 'args' => $response_args); |
|
427 | + } |
|
428 | + $errors = $this->_get_errors($response_args); |
|
429 | + return array('status' => false, 'args' => $errors); |
|
432 | 430 | } |
433 | 431 | |
434 | 432 | |
435 | 433 | /** |
436 | - * Log a "Cleared" request. |
|
437 | - * |
|
438 | - * @param array $request |
|
434 | + * Log a "Cleared" request. |
|
435 | + * |
|
436 | + * @param array $request |
|
439 | 437 | * @param EEI_Payment $payment |
440 | 438 | * @param string $info |
441 | 439 | * @return void |
@@ -458,17 +456,17 @@ discard block |
||
458 | 456 | $n = 0; |
459 | 457 | while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
460 | 458 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
461 | - ? $data_array["L_ERRORCODE{$n}"] |
|
462 | - : ''; |
|
459 | + ? $data_array["L_ERRORCODE{$n}"] |
|
460 | + : ''; |
|
463 | 461 | $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
464 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
465 | - : ''; |
|
462 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
463 | + : ''; |
|
466 | 464 | $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
467 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
468 | - : ''; |
|
465 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
466 | + : ''; |
|
469 | 467 | $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
470 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
471 | - : ''; |
|
468 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
469 | + : ''; |
|
472 | 470 | |
473 | 471 | if ( $n === 0 ) { |
474 | 472 | $errors = array( |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | *@param array $settings_array |
98 | 98 | */ |
99 | - public function set_settings( $settings_array ) { |
|
99 | + public function set_settings($settings_array) { |
|
100 | 100 | parent::set_settings($settings_array); |
101 | 101 | // Redirect URL. |
102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | * @return \EE_Payment|\EEI_Payment |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
119 | + if ( ! $payment instanceof EEI_Payment) { |
|
120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
122 | 122 | return $payment; |
123 | 123 | } |
124 | 124 | $transaction = $payment->transaction(); |
125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
128 | 128 | return $payment; |
129 | 129 | } |
130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
131 | 131 | $primary_registration = $transaction->primary_registration(); |
132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
141 | 141 | 'RETURNURL' => $return_url, |
142 | 142 | 'CANCELURL' => $cancel_url, |
143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
147 | 147 | ); |
148 | 148 | |
149 | 149 | // Show itemized list. |
150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
151 | 151 | $item_num = 0; |
152 | 152 | $itemized_sum = 0; |
153 | 153 | $total_line_items = $transaction->total_line_item(); |
154 | 154 | // Go through each item in the list. |
155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
156 | + if ($line_item instanceof EE_Line_Item) { |
|
157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $unit_price = $line_item->unit_price(); |
163 | 163 | $line_item_quantity = $line_item->quantity(); |
164 | 164 | // This is a discount. |
165 | - if ( $line_item->is_percent() ) { |
|
165 | + if ($line_item->is_percent()) { |
|
166 | 166 | $unit_price = $line_item->total(); |
167 | 167 | $line_item_quantity = 1; |
168 | 168 | } |
169 | 169 | // Item Name. |
170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
171 | 171 | // Item description. |
172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
173 | 173 | // Cost of individual item. |
174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
175 | 175 | // Item Number. |
176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
190 | 190 | |
191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
193 | 193 | // add the difference as an extra line item. |
194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
195 | 195 | // Item Name. |
196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
197 | 197 | // Item description. |
198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
199 | 199 | // Cost of individual item. |
200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
201 | 201 | // Item Number. |
202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | } else { |
210 | 210 | // Just one Item. |
211 | 211 | // Item Name. |
212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
213 | 213 | // Item description. |
214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
215 | 215 | // Cost of individual item. |
216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
217 | 217 | // Item Number. |
218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | // Digital item is sold. |
222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
223 | 223 | // Item's sales S/H and tax amount. |
224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
228 | 228 | } |
229 | 229 | // Automatically filling out shipping and contact information. |
230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
241 | 241 | // Do not request shipping details on the PP Checkout page. |
242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
244 | 244 | |
245 | 245 | } |
246 | 246 | // Used a business/personal logo on the PayPal page. |
247 | - if ( ! empty($this->_image_url) ) { |
|
247 | + if ( ! empty($this->_image_url)) { |
|
248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
249 | 249 | } |
250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | $this |
254 | 254 | ); |
255 | 255 | // Request PayPal token. |
256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
259 | - if ( $token_rstatus['status'] ) { |
|
256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
259 | + if ($token_rstatus['status']) { |
|
260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
261 | - $payment->set_details( $response_args ); |
|
261 | + $payment->set_details($response_args); |
|
262 | 262 | |
263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
265 | 265 | } else { |
266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
268 | 268 | } else { |
269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
270 | 270 | } |
271 | - $payment->set_details( $response_args ); |
|
272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
271 | + $payment->set_details($response_args); |
|
272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | * @param EEI_Transaction $transaction |
286 | 286 | * @return EEI_Payment |
287 | 287 | */ |
288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
288 | + public function handle_payment_update($update_info, $transaction) { |
|
289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
290 | 290 | |
291 | - if ( $payment instanceof EEI_Payment ) { |
|
292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
291 | + if ($payment instanceof EEI_Payment) { |
|
292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
293 | 293 | $transaction = $payment->transaction(); |
294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
297 | 297 | return $payment; |
298 | 298 | } |
299 | 299 | $primary_registrant = $transaction->primary_registration(); |
300 | 300 | $payment_details = $payment->details(); |
301 | 301 | // Check if we still have the token. |
302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
304 | 304 | return $payment; |
305 | 305 | } |
306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
310 | 310 | ); |
311 | 311 | // Request Customer Details. |
312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
315 | - if ( $cdetails_rstatus['status'] ) { |
|
312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
315 | + if ($cdetails_rstatus['status']) { |
|
316 | 316 | // We got the PayerID so now we can Complete the transaction. |
317 | 317 | $docheckout_request_dtls = array( |
318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
324 | 324 | ); |
325 | 325 | // Payment Checkout/Capture. |
326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
329 | - if ( $docheckout_rstatus['status'] ) { |
|
326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
329 | + if ($docheckout_rstatus['status']) { |
|
330 | 330 | // All is well, payment approved. |
331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
335 | - $payment->set_details( $cdata_response_args ); |
|
336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
332 | + $payment->set_extra_accntng($primary_registration_code); |
|
333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
335 | + $payment->set_details($cdata_response_args); |
|
336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
338 | 338 | } else { |
339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
341 | 341 | } else { |
342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
343 | 343 | } |
344 | - $payment->set_details( $docheckout_response_args ); |
|
345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
344 | + $payment->set_details($docheckout_response_args); |
|
345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
346 | 346 | } |
347 | 347 | } else { |
348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
350 | 350 | } else { |
351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
352 | 352 | } |
353 | - $payment->set_details( $cdata_response_args ); |
|
354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
353 | + $payment->set_details($cdata_response_args); |
|
354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
355 | 355 | } |
356 | 356 | } else { |
357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param EEI_Payment $payment |
371 | 371 | * @return mixed |
372 | 372 | */ |
373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
374 | 374 | $request_dtls = array( |
375 | 375 | 'VERSION' => '204.0', |
376 | - 'USER' => urlencode( $this->_api_username ), |
|
377 | - 'PWD' => urlencode( $this->_api_password ), |
|
378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
376 | + 'USER' => urlencode($this->_api_username), |
|
377 | + 'PWD' => urlencode($this->_api_password), |
|
378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
379 | 379 | ); |
380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
380 | + $dtls = array_merge($request_dtls, $request_params); |
|
381 | 381 | |
382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
383 | 383 | // Request Customer Details. |
384 | 384 | $request_response = wp_remote_post( |
385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | 'httpversion' => '1.1', |
390 | 390 | 'cookies' => array(), |
391 | 391 | 'headers' => array(), |
392 | - 'body' => http_build_query( $dtls ) |
|
392 | + 'body' => http_build_query($dtls) |
|
393 | 393 | ) |
394 | 394 | ); |
395 | 395 | // Log the response. |
396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
397 | 397 | |
398 | 398 | return $request_response; |
399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param mixed $request_response |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public function _ppExpress_check_response( $request_response ) { |
|
409 | - if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
|
408 | + public function _ppExpress_check_response($request_response) { |
|
409 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
410 | 410 | // If we got here then there was an error in this request. |
411 | 411 | return array('status' => false, 'args' => $request_response); |
412 | 412 | } |
413 | 413 | $response_args = array(); |
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
415 | 415 | if ( ! isset($response_args['ACK'])) { |
416 | 416 | return array('status' => false, 'args' => $request_response); |
417 | 417 | } |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | * @param string $info |
441 | 441 | * @return void |
442 | 442 | */ |
443 | - private function _log_clean_request($request, $payment, $info ) { |
|
443 | + private function _log_clean_request($request, $payment, $info) { |
|
444 | 444 | $cleaned_request_data = $request; |
445 | 445 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
446 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
446 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | * @param array $data_array |
454 | 454 | * @return array |
455 | 455 | */ |
456 | - private function _get_errors( $data_array ) { |
|
456 | + private function _get_errors($data_array) { |
|
457 | 457 | $errors = array(); |
458 | 458 | $n = 0; |
459 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
459 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
460 | 460 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
461 | 461 | ? $data_array["L_ERRORCODE{$n}"] |
462 | 462 | : ''; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | ? $data_array["L_LONGMESSAGE{$n}"] |
471 | 471 | : ''; |
472 | 472 | |
473 | - if ( $n === 0 ) { |
|
473 | + if ($n === 0) { |
|
474 | 474 | $errors = array( |
475 | 475 | 'L_ERRORCODE' => $l_error_code, |
476 | 476 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | 'L_SEVERITYCODE' => $l_severity_code |
479 | 479 | ); |
480 | 480 | } else { |
481 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
482 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
483 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
484 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
481 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
482 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
483 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
484 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | $n++; |
@@ -286,41 +286,41 @@ discard block |
||
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | 288 | foreach ( $registrations as $REG_ID => $registration ) { |
289 | - /** @var $registration EE_Registration */ |
|
290 | - // has this registration lost it's space ? |
|
289 | + /** @var $registration EE_Registration */ |
|
290 | + // has this registration lost it's space ? |
|
291 | 291 | if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
292 | 292 | $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
293 | 293 | continue; |
294 | 294 | } |
295 | - // event requires admin approval |
|
296 | - if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
297 | - // add event to list of events with pre-approval reg status |
|
298 | - $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
299 | - do_action( |
|
300 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
301 | - $registration->event(), |
|
302 | - $this |
|
303 | - ); |
|
304 | - continue; |
|
305 | - } |
|
306 | - if ( |
|
295 | + // event requires admin approval |
|
296 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
297 | + // add event to list of events with pre-approval reg status |
|
298 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
299 | + do_action( |
|
300 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
301 | + $registration->event(), |
|
302 | + $this |
|
303 | + ); |
|
304 | + continue; |
|
305 | + } |
|
306 | + if ( |
|
307 | 307 | // returning registrant |
308 | 308 | $this->checkout->revisit |
309 | 309 | // anything other than Approved |
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | - && ( |
|
312 | - $registration->event()->is_sold_out() |
|
313 | - || $registration->event()->is_sold_out( true ) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - // add event to list of events that are sold out |
|
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
318 | - do_action( |
|
319 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
320 | - $registration->event(), |
|
321 | - $this |
|
322 | - ); |
|
323 | - continue; |
|
311 | + && ( |
|
312 | + $registration->event()->is_sold_out() |
|
313 | + || $registration->event()->is_sold_out( true ) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + // add event to list of events that are sold out |
|
317 | + $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
318 | + do_action( |
|
319 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
320 | + $registration->event(), |
|
321 | + $this |
|
322 | + ); |
|
323 | + continue; |
|
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | 326 | if ( $registration->owes_monies_and_can_pay() ) { |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | new EE_Billable_Line_Item_Filter( |
429 | 429 | EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
430 | 430 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
431 | - EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
432 | - ) |
|
431 | + EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
432 | + ) |
|
433 | 433 | ) |
434 | 434 | ) |
435 | - ); |
|
435 | + ); |
|
436 | 436 | $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
@@ -481,46 +481,46 @@ discard block |
||
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | 483 | public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
484 | - // registrations per event |
|
484 | + // registrations per event |
|
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
487 | 487 | $event_spaces_remaining = array(); |
488 | - // tickets left sorted by ID |
|
489 | - $tickets_remaining = array(); |
|
490 | - // registrations that have lost their space |
|
488 | + // tickets left sorted by ID |
|
489 | + $tickets_remaining = array(); |
|
490 | + // registrations that have lost their space |
|
491 | 491 | $ejected_registrations = array(); |
492 | 492 | foreach ( $registrations as $REG_ID => $registration ) { |
493 | - if ( |
|
494 | - $registration->status_ID() === EEM_Registration::status_id_approved |
|
495 | - || apply_filters( |
|
496 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
497 | - false, |
|
498 | - $registration, |
|
499 | - $revisit |
|
500 | - ) |
|
501 | - ) { |
|
502 | - continue; |
|
493 | + if ( |
|
494 | + $registration->status_ID() === EEM_Registration::status_id_approved |
|
495 | + || apply_filters( |
|
496 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
497 | + false, |
|
498 | + $registration, |
|
499 | + $revisit |
|
500 | + ) |
|
501 | + ) { |
|
502 | + continue; |
|
503 | 503 | } |
504 | 504 | $EVT_ID = $registration->event_ID(); |
505 | - $ticket = $registration->ticket(); |
|
506 | - if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
507 | - $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
508 | - } |
|
509 | - if ($tickets_remaining[$ticket->ID()] > 0) { |
|
510 | - if ( ! isset($event_reg_count[$EVT_ID])) { |
|
511 | - $event_reg_count[$EVT_ID] = 0; |
|
512 | - } |
|
513 | - $event_reg_count[$EVT_ID]++; |
|
514 | - if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
515 | - $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
516 | - } |
|
517 | - } |
|
505 | + $ticket = $registration->ticket(); |
|
506 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
507 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
508 | + } |
|
509 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
510 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
511 | + $event_reg_count[$EVT_ID] = 0; |
|
512 | + } |
|
513 | + $event_reg_count[$EVT_ID]++; |
|
514 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
515 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
516 | + } |
|
517 | + } |
|
518 | 518 | if ( |
519 | 519 | $revisit |
520 | 520 | && ( |
521 | - $tickets_remaining[$ticket->ID()] === 0 |
|
522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
523 | - ) |
|
521 | + $tickets_remaining[$ticket->ID()] === 0 |
|
522 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
523 | + ) |
|
524 | 524 | ) { |
525 | 525 | $ejected_registrations[ $REG_ID ] = $registration->event(); |
526 | 526 | if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | 'layout_strategy' => new EE_Template_Layout( |
590 | 590 | array( |
591 | 591 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
592 | - . $this->_slug |
|
593 | - . DS |
|
594 | - . 'sold_out_events.template.php', |
|
592 | + . $this->_slug |
|
593 | + . DS |
|
594 | + . 'sold_out_events.template.php', |
|
595 | 595 | 'template_args' => apply_filters( |
596 | 596 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
597 | 597 | array( |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | 'layout_strategy' => new EE_Template_Layout( |
645 | 645 | array( |
646 | 646 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
647 | - . $this->_slug |
|
648 | - . DS |
|
649 | - . 'sold_out_events.template.php', |
|
647 | + . $this->_slug |
|
648 | + . DS |
|
649 | + . 'sold_out_events.template.php', |
|
650 | 650 | 'template_args' => apply_filters( |
651 | 651 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
652 | 652 | array( |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | 'layout_strategy' => new EE_Template_Layout( |
695 | 695 | array( |
696 | 696 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
697 | - . $this->_slug |
|
698 | - . DS |
|
699 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
697 | + . $this->_slug |
|
698 | + . DS |
|
699 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
700 | 700 | 'template_args' => apply_filters( |
701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
702 | 702 | array( |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | 'layout_strategy' => new EE_Template_Layout( |
735 | 735 | array( |
736 | 736 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
737 | - . $this->_slug |
|
738 | - . DS |
|
739 | - . 'no_payment_required.template.php', // layout_template |
|
737 | + . $this->_slug |
|
738 | + . DS |
|
739 | + . 'no_payment_required.template.php', // layout_template |
|
740 | 740 | 'template_args' => apply_filters( |
741 | 741 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
742 | 742 | array( |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
965 | 965 | } |
966 | 966 | $payment_methods_billing_info[ $payment_method->slug() |
967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
967 | + . '-info' ] = $this->_payment_method_billing_info( |
|
968 | 968 | $payment_method |
969 | 969 | ); |
970 | 970 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | // fill form with attendee info if applicable |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
1155 | - && $this->checkout->transaction_has_primary_registrant() |
|
1155 | + && $this->checkout->transaction_has_primary_registrant() |
|
1156 | 1156 | ) { |
1157 | 1157 | $payment_method_billing_form->populate_from_attendee( |
1158 | 1158 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | // and debug content |
1162 | 1162 | if ( |
1163 | 1163 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
1164 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1164 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1165 | 1165 | ) { |
1166 | 1166 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1167 | 1167 | $payment_method_billing_form |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | } |
1337 | 1337 | // and debug content |
1338 | 1338 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1339 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1339 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1340 | 1340 | ) { |
1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1342 | 1342 | $this->checkout->billing_form |
@@ -1506,8 +1506,8 @@ discard block |
||
1506 | 1506 | } |
1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1508 | 1508 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1509 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1511 | 1511 | ) { |
1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1513 | 1513 | array( |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | $payment_status = $payment->status(); |
1755 | 1755 | if ( |
1756 | 1756 | $payment_status === EEM_Payment::status_id_approved |
1757 | - || $payment_status === EEM_Payment::status_id_pending |
|
1757 | + || $payment_status === EEM_Payment::status_id_pending |
|
1758 | 1758 | ) { |
1759 | 1759 | return true; |
1760 | 1760 | } else { |
@@ -1980,8 +1980,8 @@ discard block |
||
1980 | 1980 | return false; |
1981 | 1981 | } |
1982 | 1982 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1983 | - instanceof |
|
1984 | - EE_Attendee |
|
1983 | + instanceof |
|
1984 | + EE_Attendee |
|
1985 | 1985 | ) { |
1986 | 1986 | EE_Error::add_error( |
1987 | 1987 | sprintf( |
@@ -2454,14 +2454,14 @@ discard block |
||
2454 | 2454 | |
2455 | 2455 | |
2456 | 2456 | |
2457 | - /** |
|
2458 | - * _validate_return |
|
2459 | - * |
|
2460 | - * @access private |
|
2461 | - * @return void |
|
2462 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
2463 | - * @throws \EE_Error |
|
2464 | - */ |
|
2457 | + /** |
|
2458 | + * _validate_return |
|
2459 | + * |
|
2460 | + * @access private |
|
2461 | + * @return void |
|
2462 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
2463 | + * @throws \EE_Error |
|
2464 | + */ |
|
2465 | 2465 | private function _validate_offsite_return() { |
2466 | 2466 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
2467 | 2467 | if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
@@ -2487,20 +2487,20 @@ discard block |
||
2487 | 2487 | ? $primary_registrant->session_ID() |
2488 | 2488 | : null; |
2489 | 2489 | // validate current Session ID and compare against valid TXN session ID |
2490 | - if ( |
|
2491 | - $invalid_TXN // if this is already true, then skip other checks |
|
2492 | - || EE_Session::instance()->id() === null |
|
2493 | - || ( |
|
2494 | - // WARNING !!! |
|
2495 | - // this could be PayPal sending back duplicate requests (ya they do that) |
|
2496 | - // or it **could** mean someone is simply registering AGAIN after having just done so |
|
2497 | - // so now we need to determine if this current TXN looks valid or not |
|
2498 | - // and whether this reg step has even been started ? |
|
2499 | - EE_Session::instance()->id() === $valid_TXN_SID |
|
2500 | - // really? you're half way through this reg step, but you never started it ? |
|
2501 | - && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
2502 | - ) |
|
2503 | - ) { |
|
2490 | + if ( |
|
2491 | + $invalid_TXN // if this is already true, then skip other checks |
|
2492 | + || EE_Session::instance()->id() === null |
|
2493 | + || ( |
|
2494 | + // WARNING !!! |
|
2495 | + // this could be PayPal sending back duplicate requests (ya they do that) |
|
2496 | + // or it **could** mean someone is simply registering AGAIN after having just done so |
|
2497 | + // so now we need to determine if this current TXN looks valid or not |
|
2498 | + // and whether this reg step has even been started ? |
|
2499 | + EE_Session::instance()->id() === $valid_TXN_SID |
|
2500 | + // really? you're half way through this reg step, but you never started it ? |
|
2501 | + && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
2502 | + ) |
|
2503 | + ) { |
|
2504 | 2504 | $invalid_TXN = true; |
2505 | 2505 | } |
2506 | 2506 | if ( $invalid_TXN ) { |
@@ -2702,19 +2702,19 @@ discard block |
||
2702 | 2702 | |
2703 | 2703 | |
2704 | 2704 | |
2705 | - /** |
|
2706 | - * __sleep |
|
2707 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
2708 | - * EE_Checkout will handle the reimplementation of itself upon waking, |
|
2709 | - * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
2710 | - * |
|
2711 | - * @return array |
|
2712 | - */ |
|
2713 | - public function __sleep() |
|
2714 | - { |
|
2715 | - // remove the reg form and the checkout |
|
2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2717 | - } |
|
2705 | + /** |
|
2706 | + * __sleep |
|
2707 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
2708 | + * EE_Checkout will handle the reimplementation of itself upon waking, |
|
2709 | + * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
2710 | + * |
|
2711 | + * @return array |
|
2712 | + */ |
|
2713 | + public function __sleep() |
|
2714 | + { |
|
2715 | + // remove the reg form and the checkout |
|
2716 | + return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2717 | + } |
|
2718 | 2718 | |
2719 | 2719 | |
2720 | 2720 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | */ |
129 | - public function __construct( EE_Checkout $checkout ) { |
|
129 | + public function __construct(EE_Checkout $checkout) { |
|
130 | 130 | $this->_slug = 'payment_options'; |
131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
133 | 133 | $this->checkout = $checkout; |
134 | 134 | $this->_reset_success_message(); |
135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param null $line_item_display |
156 | 156 | */ |
157 | - public function set_line_item_display( $line_item_display ) { |
|
157 | + public function set_line_item_display($line_item_display) { |
|
158 | 158 | $this->line_item_display = $line_item_display; |
159 | 159 | } |
160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @param boolean $handle_IPN_in_this_request |
174 | 174 | */ |
175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | public function enqueue_styles_and_scripts() { |
209 | 209 | $transaction = $this->checkout->transaction; |
210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
215 | 215 | $type_obj = $payment_method->type_obj(); |
216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
219 | 219 | $billing_form->enqueue_js(); |
220 | 220 | } |
221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // $ 0.00 transactions (no payment required) |
241 | 241 | ! $this->checkout->payment_required() |
242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
244 | 244 | && ! $this->completed() |
245 | 245 | ) { |
246 | 246 | // and if so, then we no longer need the Payment Options step |
247 | - if ( $this->is_current_step() ) { |
|
247 | + if ($this->is_current_step()) { |
|
248 | 248 | $this->checkout->generate_reg_form = false; |
249 | 249 | } |
250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
250 | + $this->checkout->remove_reg_step($this->_slug); |
|
251 | 251 | // DEBUG LOG |
252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | // load EEM_Payment_Method |
256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
257 | 257 | // get all active payment methods |
258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
259 | 259 | $this->checkout->transaction, |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | $insufficient_spaces_available = array(); |
281 | 281 | $no_payment_required = true; |
282 | 282 | // loop thru registrations to gather info |
283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
285 | 285 | $registrations, |
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
288 | + foreach ($registrations as $REG_ID => $registration) { |
|
289 | 289 | /** @var $registration EE_Registration */ |
290 | 290 | // has this registration lost it's space ? |
291 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
292 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
291 | + if (isset($ejected_registrations[$REG_ID])) { |
|
292 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | // event requires admin approval |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | 311 | && ( |
312 | 312 | $registration->event()->is_sold_out() |
313 | - || $registration->event()->is_sold_out( true ) |
|
313 | + || $registration->event()->is_sold_out(true) |
|
314 | 314 | ) |
315 | 315 | ) { |
316 | 316 | // add event to list of events that are sold out |
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
317 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
318 | 318 | do_action( |
319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
320 | 320 | $registration->event(), |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | continue; |
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
327 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
326 | + if ($registration->owes_monies_and_can_pay()) { |
|
327 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
328 | 328 | do_action( |
329 | 329 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
330 | 330 | $registration->event(), |
@@ -335,29 +335,29 @@ discard block |
||
335 | 335 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
336 | 336 | && $registration->ticket()->is_free() |
337 | 337 | ) { |
338 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
338 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | $subsections = array(); |
342 | 342 | // now decide which template to load |
343 | - if ( ! empty( $sold_out_events ) ) { |
|
344 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
343 | + if ( ! empty($sold_out_events)) { |
|
344 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
345 | 345 | } |
346 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
346 | + if ( ! empty($insufficient_spaces_available)) { |
|
347 | 347 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
348 | 348 | $insufficient_spaces_available |
349 | 349 | ); |
350 | 350 | } |
351 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
351 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
352 | 352 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
353 | 353 | $registrations_requiring_pre_approval |
354 | 354 | ); |
355 | 355 | } |
356 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
357 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
356 | + if ( ! empty($registrations_for_free_events)) { |
|
357 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
358 | 358 | } |
359 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
360 | - if ( $this->checkout->amount_owing > 0 ) { |
|
359 | + if ( ! empty($registrations_requiring_payment)) { |
|
360 | + if ($this->checkout->amount_owing > 0) { |
|
361 | 361 | // autoload Line_Item_Display classes |
362 | 362 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
363 | 363 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | /** @var EE_Line_Item $filtered_line_item_tree */ |
371 | 371 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
372 | 372 | EEH_Autoloader::register_line_item_display_autoloaders(); |
373 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
373 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
374 | 374 | $subsections['payment_options'] = $this->_display_payment_options( |
375 | 375 | $this->line_item_display->display_line_item( |
376 | 376 | $filtered_line_item_tree, |
377 | - array( 'registrations' => $registrations ) |
|
377 | + array('registrations' => $registrations) |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
381 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
381 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
382 | 382 | } |
383 | 383 | $no_payment_required = false; |
384 | 384 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $this->_save_selected_method_of_payment(); |
388 | 388 | |
389 | 389 | $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
390 | - $subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required ); |
|
390 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
391 | 391 | |
392 | 392 | return new EE_Form_Section_Proper( |
393 | 393 | array( |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | * @return \EE_Line_Item_Filter_Collection |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
418 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
417 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
418 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
419 | 419 | return $line_item_filter_collection; |
420 | 420 | } |
421 | - if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) { |
|
421 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
422 | 422 | return $line_item_filter_collection; |
423 | 423 | } |
424 | - if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) { |
|
424 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
425 | 425 | return $line_item_filter_collection; |
426 | 426 | } |
427 | 427 | $line_item_filter_collection->add( |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ) |
434 | 434 | ) |
435 | 435 | ); |
436 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
436 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
439 | 439 | |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @return \EE_Registration[] |
450 | 450 | * @throws \EE_Error |
451 | 451 | */ |
452 | - public static function remove_ejected_registrations( array $registrations ) { |
|
452 | + public static function remove_ejected_registrations(array $registrations) { |
|
453 | 453 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
454 | 454 | $registrations, |
455 | 455 | EE_Registry::instance()->SSN->checkout()->revisit |
456 | 456 | ); |
457 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
457 | + foreach ($registrations as $REG_ID => $registration) { |
|
458 | 458 | // has this registration lost it's space ? |
459 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
460 | - unset( $registrations[ $REG_ID ] ); |
|
459 | + if (isset($ejected_registrations[$REG_ID])) { |
|
460 | + unset($registrations[$REG_ID]); |
|
461 | 461 | continue; |
462 | 462 | } |
463 | 463 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @return array |
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
483 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
484 | 484 | // registrations per event |
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $tickets_remaining = array(); |
490 | 490 | // registrations that have lost their space |
491 | 491 | $ejected_registrations = array(); |
492 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
492 | + foreach ($registrations as $REG_ID => $registration) { |
|
493 | 493 | if ( |
494 | 494 | $registration->status_ID() === EEM_Registration::status_id_approved |
495 | 495 | || apply_filters( |
@@ -519,13 +519,13 @@ discard block |
||
519 | 519 | $revisit |
520 | 520 | && ( |
521 | 521 | $tickets_remaining[$ticket->ID()] === 0 |
522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
522 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
523 | 523 | ) |
524 | 524 | ) { |
525 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
526 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
525 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
526 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
527 | 527 | /** @type EE_Registration_Processor $registration_processor */ |
528 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
528 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
529 | 529 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
530 | 530 | $registration_processor->manually_update_registration_status( |
531 | 531 | $registration, |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | * @return void |
561 | 561 | */ |
562 | 562 | protected function _hide_reg_step_submit_button_if_revisit() { |
563 | - if ( $this->checkout->revisit ) { |
|
564 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
563 | + if ($this->checkout->revisit) { |
|
564 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
@@ -575,13 +575,13 @@ discard block |
||
575 | 575 | * @return \EE_Form_Section_Proper |
576 | 576 | * @throws \EE_Error |
577 | 577 | */ |
578 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
578 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
579 | 579 | // set some defaults |
580 | 580 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
581 | 581 | $sold_out_events = ''; |
582 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
582 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
583 | 583 | $sold_out_events .= EEH_HTML::li( |
584 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
584 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
585 | 585 | ); |
586 | 586 | } |
587 | 587 | return new EE_Form_Section_Proper( |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | 'sold_out_events_msg' => apply_filters( |
600 | 600 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
601 | 601 | sprintf( |
602 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso' ), |
|
602 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso'), |
|
603 | 603 | '<strong>', |
604 | 604 | '</strong>', |
605 | 605 | '<br />' |
@@ -624,14 +624,14 @@ discard block |
||
624 | 624 | * @return \EE_Form_Section_Proper |
625 | 625 | * @throws \EE_Error |
626 | 626 | */ |
627 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
627 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
628 | 628 | // set some defaults |
629 | 629 | $this->checkout->selected_method_of_payment = 'invoice'; |
630 | 630 | $insufficient_space_events = ''; |
631 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
632 | - if ( $event instanceof EE_Event ) { |
|
631 | + foreach ($insufficient_spaces_events_array as $event) { |
|
632 | + if ($event instanceof EE_Event) { |
|
633 | 633 | $insufficient_space_events .= EEH_HTML::li( |
634 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
634 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
635 | 635 | ); |
636 | 636 | } |
637 | 637 | } |
@@ -675,17 +675,17 @@ discard block |
||
675 | 675 | * @return \EE_Form_Section_Proper |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
678 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
679 | 679 | $events_requiring_pre_approval = ''; |
680 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
681 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
682 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
680 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
681 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
682 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
683 | 683 | EEH_HTML::span( |
684 | 684 | '', |
685 | 685 | '', |
686 | 686 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
687 | 687 | ) |
688 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
688 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'template_args' => apply_filters( |
701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
702 | 702 | array( |
703 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
703 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
704 | 704 | 'events_requiring_pre_approval_msg' => apply_filters( |
705 | 705 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
706 | 706 | __( |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @return \EE_Form_Section_Proper |
726 | 726 | * @throws \EE_Error |
727 | 727 | */ |
728 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
728 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
729 | 729 | // set some defaults |
730 | 730 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
731 | 731 | // generate no_payment_required form |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | 'ticket_count' => array(), |
746 | 746 | 'registrations_for_free_events' => $registrations_for_free_events, |
747 | 747 | 'no_payment_required_msg' => EEH_HTML::p( |
748 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
748 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
749 | 749 | ) |
750 | 750 | ) |
751 | 751 | ), |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @return \EE_Form_Section_Proper |
765 | 765 | * @throws \EE_Error |
766 | 766 | */ |
767 | - private function _display_payment_options( $transaction_details = '' ) { |
|
767 | + private function _display_payment_options($transaction_details = '') { |
|
768 | 768 | // has method_of_payment been set by no-js user? |
769 | 769 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
770 | 770 | // build payment options form |
@@ -776,14 +776,14 @@ discard block |
||
776 | 776 | 'before_payment_options' => apply_filters( |
777 | 777 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
778 | 778 | new EE_Form_Section_Proper( |
779 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
779 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
780 | 780 | ) |
781 | 781 | ), |
782 | 782 | 'payment_options' => $this->_setup_payment_options(), |
783 | 783 | 'after_payment_options' => apply_filters( |
784 | 784 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
785 | 785 | new EE_Form_Section_Proper( |
786 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
786 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
787 | 787 | ) |
788 | 788 | ), |
789 | 789 | ), |
@@ -814,10 +814,10 @@ discard block |
||
814 | 814 | * @return \EE_Form_Section_Proper |
815 | 815 | * @throws \EE_Error |
816 | 816 | */ |
817 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
817 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
818 | 818 | return new EE_Form_Section_Proper( |
819 | 819 | array( |
820 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
820 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
821 | 821 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
822 | 822 | 'subsections' => array( |
823 | 823 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -849,16 +849,16 @@ discard block |
||
849 | 849 | * @access protected |
850 | 850 | * @param array $registrations |
851 | 851 | */ |
852 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
852 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
853 | 853 | $payments = array(); |
854 | - foreach ( $registrations as $registration ) { |
|
855 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
854 | + foreach ($registrations as $registration) { |
|
855 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
856 | 856 | $payments += $registration->registration_payments(); |
857 | 857 | } |
858 | 858 | } |
859 | - if ( ! empty( $payments ) ) { |
|
860 | - foreach ( $payments as $payment ) { |
|
861 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
859 | + if ( ! empty($payments)) { |
|
860 | + foreach ($payments as $payment) { |
|
861 | + if ($payment instanceof EE_Registration_Payment) { |
|
862 | 862 | $this->checkout->amount_owing -= $payment->amount(); |
863 | 863 | } |
864 | 864 | } |
@@ -874,11 +874,11 @@ discard block |
||
874 | 874 | * @param bool $force_reset |
875 | 875 | * @return void |
876 | 876 | */ |
877 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
877 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
878 | 878 | $reset_payment_method = $force_reset |
879 | 879 | ? true |
880 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
881 | - if ( $reset_payment_method ) { |
|
880 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
881 | + if ($reset_payment_method) { |
|
882 | 882 | $this->checkout->selected_method_of_payment = null; |
883 | 883 | $this->checkout->payment_method = null; |
884 | 884 | $this->checkout->billing_form = null; |
@@ -897,12 +897,12 @@ discard block |
||
897 | 897 | * @param string $selected_method_of_payment |
898 | 898 | * @return void |
899 | 899 | */ |
900 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
901 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
900 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
901 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
902 | 902 | ? $selected_method_of_payment |
903 | 903 | : $this->checkout->selected_method_of_payment; |
904 | 904 | EE_Registry::instance()->SSN->set_session_data( |
905 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
905 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
906 | 906 | ); |
907 | 907 | } |
908 | 908 | |
@@ -918,19 +918,19 @@ discard block |
||
918 | 918 | // load payment method classes |
919 | 919 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
920 | 920 | // switch up header depending on number of available payment methods |
921 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
921 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
922 | 922 | ? apply_filters( |
923 | 923 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
924 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
924 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
925 | 925 | ) |
926 | 926 | : apply_filters( |
927 | 927 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
928 | - __( 'Method of Payment', 'event_espresso' ) |
|
928 | + __('Method of Payment', 'event_espresso') |
|
929 | 929 | ); |
930 | 930 | $available_payment_methods = array( |
931 | 931 | // display the "Payment Method" header |
932 | 932 | 'payment_method_header' => new EE_Form_Section_HTML( |
933 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
933 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
934 | 934 | ) |
935 | 935 | ); |
936 | 936 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -939,32 +939,32 @@ discard block |
||
939 | 939 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
940 | 940 | $payment_methods_billing_info = array( |
941 | 941 | new EE_Form_Section_HTML( |
942 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
942 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
943 | 943 | ) |
944 | 944 | ); |
945 | 945 | // loop through payment methods |
946 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
947 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
946 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
947 | + if ($payment_method instanceof EE_Payment_Method) { |
|
948 | 948 | $payment_method_button = EEH_HTML::img( |
949 | 949 | $payment_method->button_url(), |
950 | 950 | $payment_method->name(), |
951 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
951 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
952 | 952 | 'spco-payment-method-btn-img' |
953 | 953 | ); |
954 | 954 | // check if any payment methods are set as default |
955 | 955 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
956 | 956 | if ( |
957 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
958 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
957 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
958 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
959 | 959 | ) { |
960 | 960 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
961 | 961 | $this->_save_selected_method_of_payment(); |
962 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
962 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
963 | 963 | } else { |
964 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
964 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
965 | 965 | } |
966 | - $payment_methods_billing_info[ $payment_method->slug() |
|
967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
966 | + $payment_methods_billing_info[$payment_method->slug() |
|
967 | + . '-info'] = $this->_payment_method_billing_info( |
|
968 | 968 | $payment_method |
969 | 969 | ); |
970 | 970 | } |
@@ -994,12 +994,12 @@ discard block |
||
994 | 994 | * @return EE_Payment_Method[] |
995 | 995 | */ |
996 | 996 | protected function _get_available_payment_methods() { |
997 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
997 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
998 | 998 | return $this->checkout->available_payment_methods; |
999 | 999 | } |
1000 | 1000 | $available_payment_methods = array(); |
1001 | 1001 | // load EEM_Payment_Method |
1002 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1002 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1003 | 1003 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1004 | 1004 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1005 | 1005 | // get all active payment methods |
@@ -1007,9 +1007,9 @@ discard block |
||
1007 | 1007 | $this->checkout->transaction, |
1008 | 1008 | EEM_Payment_Method::scope_cart |
1009 | 1009 | ); |
1010 | - foreach ( $payment_methods as $payment_method ) { |
|
1011 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
1012 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
1010 | + foreach ($payment_methods as $payment_method) { |
|
1011 | + if ($payment_method instanceof EE_Payment_Method) { |
|
1012 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | return $available_payment_methods; |
@@ -1024,14 +1024,14 @@ discard block |
||
1024 | 1024 | * @param array $available_payment_method_options |
1025 | 1025 | * @return \EE_Form_Section_Proper |
1026 | 1026 | */ |
1027 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
1027 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
1028 | 1028 | // generate inputs |
1029 | 1029 | return new EE_Form_Section_Proper( |
1030 | 1030 | array( |
1031 | 1031 | 'html_id' => 'ee-available-payment-method-inputs', |
1032 | 1032 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1033 | 1033 | 'subsections' => array( |
1034 | - '' => new EE_Radio_Button_Input ( |
|
1034 | + '' => new EE_Radio_Button_Input( |
|
1035 | 1035 | $available_payment_method_options, |
1036 | 1036 | array( |
1037 | 1037 | 'html_name' => 'selected_method_of_payment', |
@@ -1056,28 +1056,28 @@ discard block |
||
1056 | 1056 | * @return \EE_Form_Section_Proper |
1057 | 1057 | * @throws \EE_Error |
1058 | 1058 | */ |
1059 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
1059 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
1060 | 1060 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
1061 | 1061 | ? true |
1062 | 1062 | : false; |
1063 | 1063 | // generate the billing form for payment method |
1064 | 1064 | $billing_form = $currently_selected |
1065 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
1065 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
1066 | 1066 | : new EE_Form_Section_HTML(); |
1067 | 1067 | $this->checkout->billing_form = $currently_selected |
1068 | 1068 | ? $billing_form |
1069 | 1069 | : $this->checkout->billing_form; |
1070 | 1070 | // it's all in the details |
1071 | 1071 | $info_html = EEH_HTML::h3( |
1072 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
1072 | + __('Important information regarding your payment', 'event_espresso'), |
|
1073 | 1073 | '', |
1074 | 1074 | 'spco-payment-method-hdr' |
1075 | 1075 | ); |
1076 | 1076 | // add some info regarding the step, either from what's saved in the admin, |
1077 | 1077 | // or a default string depending on whether the PM has a billing form or not |
1078 | - if ( $payment_method->description() ) { |
|
1078 | + if ($payment_method->description()) { |
|
1079 | 1079 | $payment_method_info = $payment_method->description(); |
1080 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1080 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
1081 | 1081 | $payment_method_info = sprintf( |
1082 | 1082 | __( |
1083 | 1083 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | ); |
1088 | 1088 | } else { |
1089 | 1089 | $payment_method_info = sprintf( |
1090 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
1090 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
1091 | 1091 | $this->submit_button_text() |
1092 | 1092 | ); |
1093 | 1093 | } |
@@ -1101,13 +1101,13 @@ discard block |
||
1101 | 1101 | ); |
1102 | 1102 | return new EE_Form_Section_Proper( |
1103 | 1103 | array( |
1104 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
1104 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
1105 | 1105 | 'html_class' => 'spco-payment-method-info-dv', |
1106 | 1106 | // only display the selected or default PM |
1107 | 1107 | 'html_style' => $currently_selected ? '' : 'display:none;', |
1108 | 1108 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1109 | 1109 | 'subsections' => array( |
1110 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
1110 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
1111 | 1111 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
1112 | 1112 | ) |
1113 | 1113 | ) |
@@ -1125,15 +1125,15 @@ discard block |
||
1125 | 1125 | */ |
1126 | 1126 | public function get_billing_form_html_for_payment_method() { |
1127 | 1127 | // how have they chosen to pay? |
1128 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1128 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1129 | 1129 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1130 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1130 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1131 | 1131 | return false; |
1132 | 1132 | } |
1133 | - if ( apply_filters( |
|
1133 | + if (apply_filters( |
|
1134 | 1134 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1135 | 1135 | false |
1136 | - ) ) { |
|
1136 | + )) { |
|
1137 | 1137 | EE_Error::add_success( |
1138 | 1138 | apply_filters( |
1139 | 1139 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ); |
1149 | 1149 | } |
1150 | 1150 | // now generate billing form for selected method of payment |
1151 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1151 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1152 | 1152 | // fill form with attendee info if applicable |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1170,10 +1170,10 @@ discard block |
||
1170 | 1170 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
1171 | 1171 | ? $payment_method_billing_form->get_html() |
1172 | 1172 | : ''; |
1173 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
1173 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
1174 | 1174 | // localize validation rules for main form |
1175 | 1175 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
1176 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1176 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1177 | 1177 | return true; |
1178 | 1178 | } |
1179 | 1179 | |
@@ -1187,18 +1187,18 @@ discard block |
||
1187 | 1187 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
1188 | 1188 | * @throws \EE_Error |
1189 | 1189 | */ |
1190 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1190 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1191 | 1191 | $billing_form = $payment_method->type_obj()->billing_form( |
1192 | 1192 | $this->checkout->transaction, |
1193 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1193 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1194 | 1194 | ); |
1195 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1195 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1196 | 1196 | if ( |
1197 | 1197 | apply_filters( |
1198 | 1198 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1199 | 1199 | false |
1200 | 1200 | ) |
1201 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1201 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1202 | 1202 | ) { |
1203 | 1203 | EE_Error::add_success( |
1204 | 1204 | apply_filters( |
@@ -1240,15 +1240,15 @@ discard block |
||
1240 | 1240 | $request_param = 'selected_method_of_payment' |
1241 | 1241 | ) { |
1242 | 1242 | // is selected_method_of_payment set in the request ? |
1243 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1244 | - if ( $selected_method_of_payment ) { |
|
1243 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1244 | + if ($selected_method_of_payment) { |
|
1245 | 1245 | // sanitize it |
1246 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1247 | - ? array_shift( $selected_method_of_payment ) |
|
1246 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1247 | + ? array_shift($selected_method_of_payment) |
|
1248 | 1248 | : $selected_method_of_payment; |
1249 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1249 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1250 | 1250 | // store it in the session so that it's available for all subsequent requests including AJAX |
1251 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1251 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1252 | 1252 | } else { |
1253 | 1253 | // or is is set in the session ? |
1254 | 1254 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | ); |
1257 | 1257 | } |
1258 | 1258 | // do ya really really gotta have it? |
1259 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1259 | + if (empty($selected_method_of_payment) && $required) { |
|
1260 | 1260 | EE_Error::add_error( |
1261 | 1261 | sprintf( |
1262 | 1262 | __( |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | ), |
1266 | 1266 | '<br/>', |
1267 | 1267 | '<br/>', |
1268 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1268 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1269 | 1269 | ), |
1270 | 1270 | __FILE__, |
1271 | 1271 | __FUNCTION__, |
@@ -1292,13 +1292,13 @@ discard block |
||
1292 | 1292 | * @throws \EE_Error |
1293 | 1293 | */ |
1294 | 1294 | public function switch_payment_method() { |
1295 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1295 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1296 | 1296 | return false; |
1297 | 1297 | } |
1298 | - if ( apply_filters( |
|
1298 | + if (apply_filters( |
|
1299 | 1299 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1300 | 1300 | false |
1301 | - ) ) { |
|
1301 | + )) { |
|
1302 | 1302 | EE_Error::add_success( |
1303 | 1303 | apply_filters( |
1304 | 1304 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | ); |
1314 | 1314 | } |
1315 | 1315 | // generate billing form for selected method of payment if it hasn't been done already |
1316 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1316 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1317 | 1317 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1318 | 1318 | $this->checkout->payment_method |
1319 | 1319 | ); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | ); |
1336 | 1336 | } |
1337 | 1337 | // and debug content |
1338 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1338 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1339 | 1339 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1340 | 1340 | ) { |
1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1343,15 +1343,15 @@ discard block |
||
1343 | 1343 | ); |
1344 | 1344 | } |
1345 | 1345 | // get html and validation rules for form |
1346 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1346 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1347 | 1347 | $this->checkout->json_response->set_return_data( |
1348 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1348 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1349 | 1349 | ); |
1350 | 1350 | // localize validation rules for main form |
1351 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1352 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1351 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1352 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1353 | 1353 | } else { |
1354 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1354 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1355 | 1355 | } |
1356 | 1356 | //prevents advancement to next step |
1357 | 1357 | $this->checkout->continue_reg = false; |
@@ -1368,18 +1368,18 @@ discard block |
||
1368 | 1368 | */ |
1369 | 1369 | protected function _verify_payment_method_is_set() { |
1370 | 1370 | // generate billing form for selected method of payment if it hasn't been done already |
1371 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1371 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1372 | 1372 | // how have they chosen to pay? |
1373 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1373 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1374 | 1374 | } else { |
1375 | 1375 | // choose your own adventure based on method_of_payment |
1376 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1376 | + switch ($this->checkout->selected_method_of_payment) { |
|
1377 | 1377 | case 'events_sold_out' : |
1378 | 1378 | EE_Error::add_attention( |
1379 | 1379 | apply_filters( |
1380 | 1380 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
1381 | - __( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1382 | - 'event_espresso' ) |
|
1381 | + __('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1382 | + 'event_espresso') |
|
1383 | 1383 | ), |
1384 | 1384 | __FILE__, __FUNCTION__, __LINE__ |
1385 | 1385 | ); |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | EE_Error::add_attention( |
1390 | 1390 | apply_filters( |
1391 | 1391 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
1392 | - __( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1392 | + __('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1393 | 1393 | ), |
1394 | 1394 | __FILE__, __FUNCTION__, __LINE__ |
1395 | 1395 | ); |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | EE_Error::add_attention( |
1400 | 1400 | apply_filters( |
1401 | 1401 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
1402 | - __( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1402 | + __('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1403 | 1403 | ), |
1404 | 1404 | __FILE__, __FUNCTION__, __LINE__ |
1405 | 1405 | ); |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | } |
1410 | 1410 | } |
1411 | 1411 | // verify payment method |
1412 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1412 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1413 | 1413 | // get payment method for selected method of payment |
1414 | 1414 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1415 | 1415 | } |
@@ -1428,25 +1428,25 @@ discard block |
||
1428 | 1428 | * @throws \EE_Error |
1429 | 1429 | */ |
1430 | 1430 | public function save_payer_details_via_ajax() { |
1431 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1431 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1432 | 1432 | return; |
1433 | 1433 | } |
1434 | 1434 | // generate billing form for selected method of payment if it hasn't been done already |
1435 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1435 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1436 | 1436 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1437 | 1437 | $this->checkout->payment_method |
1438 | 1438 | ); |
1439 | 1439 | } |
1440 | 1440 | // generate primary attendee from payer info if applicable |
1441 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1441 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1442 | 1442 | $attendee = $this->_create_attendee_from_request_data(); |
1443 | - if ( $attendee instanceof EE_Attendee ) { |
|
1444 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1445 | - if ( $registration->is_primary_registrant() ) { |
|
1443 | + if ($attendee instanceof EE_Attendee) { |
|
1444 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1445 | + if ($registration->is_primary_registrant()) { |
|
1446 | 1446 | $this->checkout->primary_attendee_obj = $attendee; |
1447 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1448 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1449 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1447 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1448 | + $registration->set_attendee_id($attendee->ID()); |
|
1449 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | } |
@@ -1464,50 +1464,50 @@ discard block |
||
1464 | 1464 | */ |
1465 | 1465 | protected function _create_attendee_from_request_data() { |
1466 | 1466 | // get State ID |
1467 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1468 | - if ( ! empty( $STA_ID ) ) { |
|
1467 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1468 | + if ( ! empty($STA_ID)) { |
|
1469 | 1469 | // can we get state object from name ? |
1470 | - EE_Registry::instance()->load_model( 'State' ); |
|
1471 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1472 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1470 | + EE_Registry::instance()->load_model('State'); |
|
1471 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1472 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1473 | 1473 | } |
1474 | 1474 | // get Country ISO |
1475 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1476 | - if ( ! empty( $CNT_ISO ) ) { |
|
1475 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1476 | + if ( ! empty($CNT_ISO)) { |
|
1477 | 1477 | // can we get country object from name ? |
1478 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1478 | + EE_Registry::instance()->load_model('Country'); |
|
1479 | 1479 | $country = EEM_Country::instance()->get_col( |
1480 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1480 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1481 | 1481 | 'CNT_ISO' |
1482 | 1482 | ); |
1483 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1483 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1484 | 1484 | } |
1485 | 1485 | // grab attendee data |
1486 | 1486 | $attendee_data = array( |
1487 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1488 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1489 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1490 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1491 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1492 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1487 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1488 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1489 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1490 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1491 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1492 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1493 | 1493 | 'STA_ID' => $STA_ID, |
1494 | 1494 | 'CNT_ISO' => $CNT_ISO, |
1495 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1496 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1495 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1496 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1497 | 1497 | ); |
1498 | 1498 | // validate the email address since it is the most important piece of info |
1499 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1499 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1500 | 1500 | EE_Error::add_error( |
1501 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1501 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1502 | 1502 | __FILE__, |
1503 | 1503 | __FUNCTION__, |
1504 | 1504 | __LINE__ |
1505 | 1505 | ); |
1506 | 1506 | } |
1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1508 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1508 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1509 | + && ! empty($attendee_data['ATT_lname']) |
|
1510 | + && ! empty($attendee_data['ATT_email']) |
|
1511 | 1511 | ) { |
1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1513 | 1513 | array( |
@@ -1516,19 +1516,19 @@ discard block |
||
1516 | 1516 | 'ATT_email' => $attendee_data['ATT_email'] |
1517 | 1517 | ) |
1518 | 1518 | ); |
1519 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1519 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1520 | 1520 | return $existing_attendee; |
1521 | 1521 | } |
1522 | 1522 | } |
1523 | 1523 | // no existing attendee? kk let's create a new one |
1524 | 1524 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1525 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1525 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1526 | 1526 | ? $attendee_data['ATT_fname'] |
1527 | 1527 | : $attendee_data['ATT_email']; |
1528 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1528 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1529 | 1529 | ? $attendee_data['ATT_lname'] |
1530 | 1530 | : $attendee_data['ATT_email']; |
1531 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1531 | + return EE_Attendee::new_instance($attendee_data); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | |
@@ -1546,26 +1546,26 @@ discard block |
||
1546 | 1546 | // how have they chosen to pay? |
1547 | 1547 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1548 | 1548 | ? 'no_payment_required' |
1549 | - : $this->_get_selected_method_of_payment( true ); |
|
1549 | + : $this->_get_selected_method_of_payment(true); |
|
1550 | 1550 | // choose your own adventure based on method_of_payment |
1551 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1551 | + switch ($this->checkout->selected_method_of_payment) { |
|
1552 | 1552 | |
1553 | 1553 | case 'events_sold_out' : |
1554 | 1554 | $this->checkout->redirect = true; |
1555 | 1555 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1556 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1556 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1557 | 1557 | // mark this reg step as completed |
1558 | 1558 | $this->set_completed(); |
1559 | 1559 | return false; |
1560 | 1560 | break; |
1561 | 1561 | |
1562 | 1562 | case 'payments_closed' : |
1563 | - if ( apply_filters( |
|
1563 | + if (apply_filters( |
|
1564 | 1564 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1565 | 1565 | false |
1566 | - ) ) { |
|
1566 | + )) { |
|
1567 | 1567 | EE_Error::add_success( |
1568 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1568 | + __('no payment required at this time.', 'event_espresso'), |
|
1569 | 1569 | __FILE__, |
1570 | 1570 | __FUNCTION__, |
1571 | 1571 | __LINE__ |
@@ -1577,12 +1577,12 @@ discard block |
||
1577 | 1577 | break; |
1578 | 1578 | |
1579 | 1579 | case 'no_payment_required' : |
1580 | - if ( apply_filters( |
|
1580 | + if (apply_filters( |
|
1581 | 1581 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1582 | 1582 | false |
1583 | - ) ) { |
|
1583 | + )) { |
|
1584 | 1584 | EE_Error::add_success( |
1585 | - __( 'no payment required.', 'event_espresso' ), |
|
1585 | + __('no payment required.', 'event_espresso'), |
|
1586 | 1586 | __FILE__, |
1587 | 1587 | __FUNCTION__, |
1588 | 1588 | __LINE__ |
@@ -1602,15 +1602,15 @@ discard block |
||
1602 | 1602 | EE_Registry::instance()->SSN->checkout()->revisit |
1603 | 1603 | ); |
1604 | 1604 | // calculate difference between the two arrays |
1605 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
1606 | - if ( empty( $registrations ) ) { |
|
1605 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
1606 | + if (empty($registrations)) { |
|
1607 | 1607 | $this->_redirect_because_event_sold_out(); |
1608 | 1608 | return false; |
1609 | 1609 | } |
1610 | 1610 | $payment_successful = $this->_process_payment(); |
1611 | - if ( $payment_successful ) { |
|
1611 | + if ($payment_successful) { |
|
1612 | 1612 | $this->checkout->continue_reg = true; |
1613 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1613 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1614 | 1614 | } else { |
1615 | 1615 | $this->checkout->continue_reg = false; |
1616 | 1616 | } |
@@ -1631,10 +1631,10 @@ discard block |
||
1631 | 1631 | $this->checkout->continue_reg = false; |
1632 | 1632 | // set redirect URL |
1633 | 1633 | $this->checkout->redirect_url = add_query_arg( |
1634 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1634 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1635 | 1635 | $this->checkout->current_step->reg_step_url() |
1636 | 1636 | ); |
1637 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1637 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1638 | 1638 | } |
1639 | 1639 | |
1640 | 1640 | |
@@ -1647,8 +1647,8 @@ discard block |
||
1647 | 1647 | * @return void |
1648 | 1648 | * @throws \EE_Error |
1649 | 1649 | */ |
1650 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1651 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1650 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1651 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1652 | 1652 | case EE_PMT_Base::offsite : |
1653 | 1653 | break; |
1654 | 1654 | case EE_PMT_Base::onsite : |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | public function update_reg_step() { |
1672 | 1672 | $success = true; |
1673 | 1673 | // if payment required |
1674 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1674 | + if ($this->checkout->transaction->total() > 0) { |
|
1675 | 1675 | do_action( |
1676 | 1676 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1677 | 1677 | $this->checkout->transaction |
@@ -1679,13 +1679,13 @@ discard block |
||
1679 | 1679 | // attempt payment via payment method |
1680 | 1680 | $success = $this->process_reg_step(); |
1681 | 1681 | } |
1682 | - if ( $success && ! $this->checkout->redirect ) { |
|
1682 | + if ($success && ! $this->checkout->redirect) { |
|
1683 | 1683 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1684 | 1684 | $this->checkout->transaction->ID() |
1685 | 1685 | ); |
1686 | 1686 | // set return URL |
1687 | 1687 | $this->checkout->redirect_url = add_query_arg( |
1688 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1688 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1689 | 1689 | $this->checkout->thank_you_page_url |
1690 | 1690 | ); |
1691 | 1691 | } |
@@ -1703,36 +1703,36 @@ discard block |
||
1703 | 1703 | */ |
1704 | 1704 | private function _process_payment() { |
1705 | 1705 | // basically confirm that the event hasn't sold out since they hit the page |
1706 | - if ( ! $this->_last_second_ticket_verifications() ) { |
|
1706 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
1707 | 1707 | return false; |
1708 | 1708 | } |
1709 | 1709 | // ya gotta make a choice man |
1710 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1710 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1711 | 1711 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1712 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1712 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1713 | 1713 | ); |
1714 | 1714 | return false; |
1715 | 1715 | } |
1716 | 1716 | // get EE_Payment_Method object |
1717 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1717 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1718 | 1718 | return false; |
1719 | 1719 | } |
1720 | 1720 | // setup billing form |
1721 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1721 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1722 | 1722 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1723 | 1723 | $this->checkout->payment_method |
1724 | 1724 | ); |
1725 | 1725 | // bad billing form ? |
1726 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1726 | + if ( ! $this->_billing_form_is_valid()) { |
|
1727 | 1727 | return false; |
1728 | 1728 | } |
1729 | 1729 | } |
1730 | 1730 | // ensure primary registrant has been fully processed |
1731 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1731 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1732 | 1732 | return false; |
1733 | 1733 | } |
1734 | 1734 | // if session is close to expiring (under 10 minutes by default) |
1735 | - if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) { |
|
1735 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
1736 | 1736 | // add some time to session expiration so that payment can be completed |
1737 | 1737 | EE_Registry::instance()->SSN->extend_expiration(); |
1738 | 1738 | } |
@@ -1741,12 +1741,12 @@ discard block |
||
1741 | 1741 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1742 | 1742 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1743 | 1743 | // attempt payment |
1744 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1744 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1745 | 1745 | // process results |
1746 | - $payment = $this->_validate_payment( $payment ); |
|
1747 | - $payment = $this->_post_payment_processing( $payment ); |
|
1746 | + $payment = $this->_validate_payment($payment); |
|
1747 | + $payment = $this->_post_payment_processing($payment); |
|
1748 | 1748 | // verify payment |
1749 | - if ( $payment instanceof EE_Payment ) { |
|
1749 | + if ($payment instanceof EE_Payment) { |
|
1750 | 1750 | // store that for later |
1751 | 1751 | $this->checkout->payment = $payment; |
1752 | 1752 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | } else { |
1761 | 1761 | return false; |
1762 | 1762 | } |
1763 | - } else if ( $payment === true ) { |
|
1763 | + } else if ($payment === true) { |
|
1764 | 1764 | // please note that offline payment methods will NOT make a payment, |
1765 | 1765 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1766 | 1766 | $this->checkout->payment = $payment; |
@@ -1780,22 +1780,22 @@ discard block |
||
1780 | 1780 | */ |
1781 | 1781 | protected function _last_second_ticket_verifications() { |
1782 | 1782 | // don't bother re-validating if not a return visit |
1783 | - if ( ! $this->checkout->revisit ) { |
|
1783 | + if ( ! $this->checkout->revisit) { |
|
1784 | 1784 | return true; |
1785 | 1785 | } |
1786 | 1786 | $registrations = $this->checkout->transaction->registrations(); |
1787 | - if ( empty( $registrations ) ) { |
|
1787 | + if (empty($registrations)) { |
|
1788 | 1788 | return false; |
1789 | 1789 | } |
1790 | - foreach ( $registrations as $registration ) { |
|
1791 | - if ( $registration instanceof EE_Registration ) { |
|
1790 | + foreach ($registrations as $registration) { |
|
1791 | + if ($registration instanceof EE_Registration) { |
|
1792 | 1792 | $event = $registration->event_obj(); |
1793 | - if ( $event instanceof EE_Event && $event->is_sold_out( true ) ) { |
|
1793 | + if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
1794 | 1794 | EE_Error::add_error( |
1795 | 1795 | apply_filters( |
1796 | 1796 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
1797 | 1797 | sprintf( |
1798 | - __( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ), |
|
1798 | + __('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'), |
|
1799 | 1799 | $event->name() |
1800 | 1800 | ) |
1801 | 1801 | ), |
@@ -1825,7 +1825,7 @@ discard block |
||
1825 | 1825 | ); |
1826 | 1826 | $html = $payment_method_billing_info->get_html(); |
1827 | 1827 | $html .= $this->checkout->redirect_form; |
1828 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1828 | + EE_Registry::instance()->REQ->add_output($html); |
|
1829 | 1829 | return true; |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1839,28 +1839,28 @@ discard block |
||
1839 | 1839 | * @throws \EE_Error |
1840 | 1840 | */ |
1841 | 1841 | private function _billing_form_is_valid() { |
1842 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1842 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1843 | 1843 | return true; |
1844 | 1844 | } |
1845 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1846 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1845 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1846 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1847 | 1847 | $this->checkout->billing_form->receive_form_submission(); |
1848 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1848 | + if ($this->checkout->billing_form->is_valid()) { |
|
1849 | 1849 | return true; |
1850 | 1850 | } |
1851 | 1851 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1852 | 1852 | $error_strings = array(); |
1853 | - foreach ( $validation_errors as $validation_error ) { |
|
1854 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1853 | + foreach ($validation_errors as $validation_error) { |
|
1854 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1855 | 1855 | $form_section = $validation_error->get_form_section(); |
1856 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1856 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1857 | 1857 | $label = $form_section->html_label_text(); |
1858 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1858 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1859 | 1859 | $label = $form_section->name(); |
1860 | 1860 | } else { |
1861 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1861 | + $label = __('Validation Error', 'event_espresso'); |
|
1862 | 1862 | } |
1863 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1863 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1864 | 1864 | } |
1865 | 1865 | } |
1866 | 1866 | EE_Error::add_error( |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | 'event_espresso' |
1871 | 1871 | ), |
1872 | 1872 | '<br/>', |
1873 | - implode( '<br/>', $error_strings ) |
|
1873 | + implode('<br/>', $error_strings) |
|
1874 | 1874 | ), |
1875 | 1875 | __FILE__, |
1876 | 1876 | __FUNCTION__, |
@@ -1889,7 +1889,7 @@ discard block |
||
1889 | 1889 | } |
1890 | 1890 | } else { |
1891 | 1891 | EE_Error::add_error( |
1892 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1892 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1893 | 1893 | __FILE__, |
1894 | 1894 | __FUNCTION__, |
1895 | 1895 | __LINE__ |
@@ -1928,7 +1928,7 @@ discard block |
||
1928 | 1928 | // save the TXN ( which clears cached copy of primary_registration) |
1929 | 1929 | $this->checkout->transaction->save(); |
1930 | 1930 | // grab TXN ID and save it to the primary_registration |
1931 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1931 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1932 | 1932 | // save what we have so far |
1933 | 1933 | $primary_registration->save(); |
1934 | 1934 | return true; |
@@ -1946,7 +1946,7 @@ discard block |
||
1946 | 1946 | private function _capture_primary_registration_data_from_billing_form() { |
1947 | 1947 | // convert billing form data into an attendee |
1948 | 1948 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1949 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1949 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1950 | 1950 | EE_Error::add_error( |
1951 | 1951 | sprintf( |
1952 | 1952 | __( |
@@ -1954,7 +1954,7 @@ discard block |
||
1954 | 1954 | 'event_espresso' |
1955 | 1955 | ), |
1956 | 1956 | '<br/>', |
1957 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1957 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1958 | 1958 | ), |
1959 | 1959 | __FILE__, |
1960 | 1960 | __FUNCTION__, |
@@ -1963,7 +1963,7 @@ discard block |
||
1963 | 1963 | return false; |
1964 | 1964 | } |
1965 | 1965 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1966 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1966 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1967 | 1967 | EE_Error::add_error( |
1968 | 1968 | sprintf( |
1969 | 1969 | __( |
@@ -1971,7 +1971,7 @@ discard block |
||
1971 | 1971 | 'event_espresso' |
1972 | 1972 | ), |
1973 | 1973 | '<br/>', |
1974 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1974 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1975 | 1975 | ), |
1976 | 1976 | __FILE__, |
1977 | 1977 | __FUNCTION__, |
@@ -1979,7 +1979,7 @@ discard block |
||
1979 | 1979 | ); |
1980 | 1980 | return false; |
1981 | 1981 | } |
1982 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1982 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1983 | 1983 | instanceof |
1984 | 1984 | EE_Attendee |
1985 | 1985 | ) { |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | 'event_espresso' |
1991 | 1991 | ), |
1992 | 1992 | '<br/>', |
1993 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1993 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1994 | 1994 | ), |
1995 | 1995 | __FILE__, |
1996 | 1996 | __FUNCTION__, |
@@ -1999,9 +1999,9 @@ discard block |
||
1999 | 1999 | return false; |
2000 | 2000 | } |
2001 | 2001 | /** @type EE_Registration_Processor $registration_processor */ |
2002 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
2002 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
2003 | 2003 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
2004 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
2004 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
2005 | 2005 | return true; |
2006 | 2006 | } |
2007 | 2007 | |
@@ -2016,22 +2016,22 @@ discard block |
||
2016 | 2016 | * @throws \EE_Error |
2017 | 2017 | */ |
2018 | 2018 | private function _get_payment_method_for_selected_method_of_payment() { |
2019 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
2019 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
2020 | 2020 | $this->_redirect_because_event_sold_out(); |
2021 | 2021 | return null; |
2022 | 2022 | } |
2023 | 2023 | // get EE_Payment_Method object |
2024 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
2025 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
2024 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
2025 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
2026 | 2026 | } else { |
2027 | 2027 | // load EEM_Payment_Method |
2028 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
2028 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
2029 | 2029 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
2030 | 2030 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
2031 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
2031 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
2032 | 2032 | } |
2033 | 2033 | // verify $payment_method |
2034 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
2034 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
2035 | 2035 | // not a payment |
2036 | 2036 | EE_Error::add_error( |
2037 | 2037 | sprintf( |
@@ -2040,7 +2040,7 @@ discard block |
||
2040 | 2040 | 'event_espresso' |
2041 | 2041 | ), |
2042 | 2042 | '<br/>', |
2043 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2043 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2044 | 2044 | ), |
2045 | 2045 | __FILE__, |
2046 | 2046 | __FUNCTION__, |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | return null; |
2050 | 2050 | } |
2051 | 2051 | // and verify it has a valid Payment_Method Type object |
2052 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
2052 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
2053 | 2053 | // not a payment |
2054 | 2054 | EE_Error::add_error( |
2055 | 2055 | sprintf( |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | 'event_espresso' |
2059 | 2059 | ), |
2060 | 2060 | '<br/>', |
2061 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2061 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2062 | 2062 | ), |
2063 | 2063 | __FILE__, |
2064 | 2064 | __FUNCTION__, |
@@ -2079,29 +2079,29 @@ discard block |
||
2079 | 2079 | * @return mixed EE_Payment | boolean |
2080 | 2080 | * @throws \EE_Error |
2081 | 2081 | */ |
2082 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
2082 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
2083 | 2083 | $payment = null; |
2084 | 2084 | $this->checkout->transaction->save(); |
2085 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2086 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
2085 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2086 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
2087 | 2087 | return false; |
2088 | 2088 | } |
2089 | 2089 | try { |
2090 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
2090 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
2091 | 2091 | // generate payment object |
2092 | 2092 | $payment = $payment_processor->process_payment( |
2093 | 2093 | $payment_method, |
2094 | 2094 | $this->checkout->transaction, |
2095 | 2095 | $this->checkout->amount_owing, |
2096 | 2096 | $this->checkout->billing_form, |
2097 | - $this->_get_return_url( $payment_method ), |
|
2097 | + $this->_get_return_url($payment_method), |
|
2098 | 2098 | 'CART', |
2099 | 2099 | $this->checkout->admin_request, |
2100 | 2100 | true, |
2101 | 2101 | $this->reg_step_url() |
2102 | 2102 | ); |
2103 | - } catch ( Exception $e ) { |
|
2104 | - $this->_handle_payment_processor_exception( $e ); |
|
2103 | + } catch (Exception $e) { |
|
2104 | + $this->_handle_payment_processor_exception($e); |
|
2105 | 2105 | } |
2106 | 2106 | return $payment; |
2107 | 2107 | } |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | * @return void |
2117 | 2117 | * @throws \EE_Error |
2118 | 2118 | */ |
2119 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
2119 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
2120 | 2120 | EE_Error::add_error( |
2121 | 2121 | sprintf( |
2122 | 2122 | __( |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | 'event_espresso' |
2125 | 2125 | ), |
2126 | 2126 | '<br/>', |
2127 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
2127 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
2128 | 2128 | $e->getMessage(), |
2129 | 2129 | $e->getFile(), |
2130 | 2130 | $e->getLine() |
@@ -2145,9 +2145,9 @@ discard block |
||
2145 | 2145 | * @return string |
2146 | 2146 | * @throws \EE_Error |
2147 | 2147 | */ |
2148 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
2148 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
2149 | 2149 | $return_url = ''; |
2150 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
2150 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
2151 | 2151 | case EE_PMT_Base::offsite : |
2152 | 2152 | $return_url = add_query_arg( |
2153 | 2153 | array( |
@@ -2176,12 +2176,12 @@ discard block |
||
2176 | 2176 | * @return EE_Payment | FALSE |
2177 | 2177 | * @throws \EE_Error |
2178 | 2178 | */ |
2179 | - private function _validate_payment( $payment = null ) { |
|
2180 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
2179 | + private function _validate_payment($payment = null) { |
|
2180 | + if ($this->checkout->payment_method->is_off_line()) { |
|
2181 | 2181 | return true; |
2182 | 2182 | } |
2183 | 2183 | // verify payment object |
2184 | - if ( ! $payment instanceof EE_Payment ) { |
|
2184 | + if ( ! $payment instanceof EE_Payment) { |
|
2185 | 2185 | // not a payment |
2186 | 2186 | EE_Error::add_error( |
2187 | 2187 | sprintf( |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | 'event_espresso' |
2191 | 2191 | ), |
2192 | 2192 | '<br/>', |
2193 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2193 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2194 | 2194 | ), |
2195 | 2195 | __FILE__, |
2196 | 2196 | __FUNCTION__, |
@@ -2211,27 +2211,27 @@ discard block |
||
2211 | 2211 | * @return bool |
2212 | 2212 | * @throws \EE_Error |
2213 | 2213 | */ |
2214 | - private function _post_payment_processing( $payment = null ) { |
|
2214 | + private function _post_payment_processing($payment = null) { |
|
2215 | 2215 | // Off-Line payment? |
2216 | - if ( $payment === true ) { |
|
2216 | + if ($payment === true) { |
|
2217 | 2217 | //$this->_setup_redirect_for_next_step(); |
2218 | 2218 | return true; |
2219 | 2219 | // On-Site payment? |
2220 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
2221 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
2220 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
2221 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
2222 | 2222 | //$this->_setup_redirect_for_next_step(); |
2223 | 2223 | $this->checkout->continue_reg = false; |
2224 | 2224 | } |
2225 | 2225 | // Off-Site payment? |
2226 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
2226 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
2227 | 2227 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
2228 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
2229 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
2228 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
2229 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
2230 | 2230 | $this->checkout->redirect = true; |
2231 | 2231 | $this->checkout->redirect_form = $payment->redirect_form(); |
2232 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
2232 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
2233 | 2233 | // set JSON response |
2234 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
2234 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
2235 | 2235 | // set cron job for finalizing the TXN |
2236 | 2236 | // in case the user does not return from the off-site gateway |
2237 | 2237 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | $this->checkout->transaction->ID() |
2240 | 2240 | ); |
2241 | 2241 | // and lastly, let's bump the payment status to pending |
2242 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
2242 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
2243 | 2243 | $payment->save(); |
2244 | 2244 | } else { |
2245 | 2245 | // not a payment |
@@ -2251,7 +2251,7 @@ discard block |
||
2251 | 2251 | 'event_espresso' |
2252 | 2252 | ), |
2253 | 2253 | '<br/>', |
2254 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2254 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2255 | 2255 | ), |
2256 | 2256 | __FILE__, |
2257 | 2257 | __FUNCTION__, |
@@ -2289,21 +2289,21 @@ discard block |
||
2289 | 2289 | * @return bool |
2290 | 2290 | * @throws \EE_Error |
2291 | 2291 | */ |
2292 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
2292 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
2293 | 2293 | // off-line payment? carry on |
2294 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
2294 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
2295 | 2295 | return true; |
2296 | 2296 | } |
2297 | 2297 | // verify payment validity |
2298 | - if ( $payment instanceof EE_Payment ) { |
|
2299 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
2298 | + if ($payment instanceof EE_Payment) { |
|
2299 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
2300 | 2300 | $msg = $payment->gateway_response(); |
2301 | 2301 | // check results |
2302 | - switch ( $payment->status() ) { |
|
2302 | + switch ($payment->status()) { |
|
2303 | 2303 | // good payment |
2304 | 2304 | case EEM_Payment::status_id_approved : |
2305 | 2305 | EE_Error::add_success( |
2306 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
2306 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
2307 | 2307 | __FILE__, |
2308 | 2308 | __FUNCTION__, |
2309 | 2309 | __LINE__ |
@@ -2312,45 +2312,45 @@ discard block |
||
2312 | 2312 | break; |
2313 | 2313 | // slow payment |
2314 | 2314 | case EEM_Payment::status_id_pending : |
2315 | - if ( empty( $msg ) ) { |
|
2315 | + if (empty($msg)) { |
|
2316 | 2316 | $msg = __( |
2317 | 2317 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2318 | 2318 | 'event_espresso' |
2319 | 2319 | ); |
2320 | 2320 | } |
2321 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2321 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2322 | 2322 | return true; |
2323 | 2323 | break; |
2324 | 2324 | // don't wanna payment |
2325 | 2325 | case EEM_Payment::status_id_cancelled : |
2326 | - if ( empty( $msg ) ) { |
|
2326 | + if (empty($msg)) { |
|
2327 | 2327 | $msg = _n( |
2328 | 2328 | 'Payment cancelled. Please try again.', |
2329 | 2329 | 'Payment cancelled. Please try again or select another method of payment.', |
2330 | - count( $this->checkout->available_payment_methods ), |
|
2330 | + count($this->checkout->available_payment_methods), |
|
2331 | 2331 | 'event_espresso' |
2332 | 2332 | ); |
2333 | 2333 | } |
2334 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2334 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2335 | 2335 | return false; |
2336 | 2336 | break; |
2337 | 2337 | // not enough payment |
2338 | 2338 | case EEM_Payment::status_id_declined : |
2339 | - if ( empty( $msg ) ) { |
|
2339 | + if (empty($msg)) { |
|
2340 | 2340 | $msg = _n( |
2341 | 2341 | 'We\'re sorry but your payment was declined. Please try again.', |
2342 | 2342 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2343 | - count( $this->checkout->available_payment_methods ), |
|
2343 | + count($this->checkout->available_payment_methods), |
|
2344 | 2344 | 'event_espresso' |
2345 | 2345 | ); |
2346 | 2346 | } |
2347 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2347 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2348 | 2348 | return false; |
2349 | 2349 | break; |
2350 | 2350 | // bad payment |
2351 | 2351 | case EEM_Payment::status_id_failed : |
2352 | - if ( ! empty( $msg ) ) { |
|
2353 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2352 | + if ( ! empty($msg)) { |
|
2353 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2354 | 2354 | return false; |
2355 | 2355 | } |
2356 | 2356 | // default to error below |
@@ -2359,7 +2359,7 @@ discard block |
||
2359 | 2359 | } |
2360 | 2360 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2361 | 2361 | // the payment processing is just running slower than the registrant's request |
2362 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2362 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2363 | 2363 | return true; |
2364 | 2364 | } |
2365 | 2365 | EE_Error::add_error( |
@@ -2369,7 +2369,7 @@ discard block |
||
2369 | 2369 | 'event_espresso' |
2370 | 2370 | ), |
2371 | 2371 | '<br/>', |
2372 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2372 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2373 | 2373 | ), |
2374 | 2374 | __FILE__, |
2375 | 2375 | __FUNCTION__, |
@@ -2402,13 +2402,13 @@ discard block |
||
2402 | 2402 | public function process_gateway_response() { |
2403 | 2403 | $payment = null; |
2404 | 2404 | // how have they chosen to pay? |
2405 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2405 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2406 | 2406 | // get EE_Payment_Method object |
2407 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2407 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2408 | 2408 | $this->checkout->continue_reg = false; |
2409 | 2409 | return false; |
2410 | 2410 | } |
2411 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2411 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2412 | 2412 | return false; |
2413 | 2413 | } |
2414 | 2414 | $this->_validate_offsite_return(); |
@@ -2422,23 +2422,23 @@ discard block |
||
2422 | 2422 | // true |
2423 | 2423 | //); |
2424 | 2424 | // verify TXN |
2425 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2425 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2426 | 2426 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2427 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2427 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2428 | 2428 | $this->checkout->continue_reg = false; |
2429 | 2429 | return false; |
2430 | 2430 | } |
2431 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2432 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2433 | - $payment = $this->_validate_payment( $payment ); |
|
2431 | + $payment = $this->_process_off_site_payment($gateway); |
|
2432 | + $payment = $this->_process_cancelled_payments($payment); |
|
2433 | + $payment = $this->_validate_payment($payment); |
|
2434 | 2434 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2435 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2435 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2436 | 2436 | //$this->_setup_redirect_for_next_step(); |
2437 | 2437 | // store that for later |
2438 | 2438 | $this->checkout->payment = $payment; |
2439 | 2439 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2440 | 2440 | // because we will complete this step during the IPN processing then |
2441 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2441 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2442 | 2442 | $this->set_completed(); |
2443 | 2443 | } |
2444 | 2444 | return true; |
@@ -2463,21 +2463,21 @@ discard block |
||
2463 | 2463 | * @throws \EE_Error |
2464 | 2464 | */ |
2465 | 2465 | private function _validate_offsite_return() { |
2466 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2467 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2466 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2467 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2468 | 2468 | // Houston... we might have a problem |
2469 | 2469 | $invalid_TXN = false; |
2470 | 2470 | // first gather some info |
2471 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2471 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2472 | 2472 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2473 | 2473 | ? $valid_TXN->primary_registration() |
2474 | 2474 | : null; |
2475 | 2475 | // let's start by retrieving the cart for this TXN |
2476 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2477 | - if ( $cart instanceof EE_Cart ) { |
|
2476 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2477 | + if ($cart instanceof EE_Cart) { |
|
2478 | 2478 | // verify that the current cart has tickets |
2479 | 2479 | $tickets = $cart->get_tickets(); |
2480 | - if ( empty( $tickets ) ) { |
|
2480 | + if (empty($tickets)) { |
|
2481 | 2481 | $invalid_TXN = true; |
2482 | 2482 | } |
2483 | 2483 | } else { |
@@ -2503,21 +2503,21 @@ discard block |
||
2503 | 2503 | ) { |
2504 | 2504 | $invalid_TXN = true; |
2505 | 2505 | } |
2506 | - if ( $invalid_TXN ) { |
|
2506 | + if ($invalid_TXN) { |
|
2507 | 2507 | // is the valid TXN completed ? |
2508 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2508 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2509 | 2509 | // has this step even been started ? |
2510 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
2511 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2510 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
2511 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2512 | 2512 | // so it **looks** like this is a double request from PayPal |
2513 | 2513 | // so let's try to pick up where we left off |
2514 | 2514 | $this->checkout->transaction = $valid_TXN; |
2515 | - $this->checkout->refresh_all_entities( true ); |
|
2515 | + $this->checkout->refresh_all_entities(true); |
|
2516 | 2516 | return; |
2517 | 2517 | } |
2518 | 2518 | } |
2519 | 2519 | // you appear to be lost? |
2520 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2520 | + $this->_redirect_wayward_request($primary_registrant); |
|
2521 | 2521 | } |
2522 | 2522 | } |
2523 | 2523 | } |
@@ -2532,14 +2532,14 @@ discard block |
||
2532 | 2532 | * @return bool |
2533 | 2533 | * @throws \EE_Error |
2534 | 2534 | */ |
2535 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2536 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2535 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2536 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2537 | 2537 | // try redirecting based on the current TXN |
2538 | 2538 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2539 | 2539 | ? $this->checkout->transaction->primary_registration() |
2540 | 2540 | : null; |
2541 | 2541 | } |
2542 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2542 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2543 | 2543 | EE_Error::add_error( |
2544 | 2544 | sprintf( |
2545 | 2545 | __( |
@@ -2547,7 +2547,7 @@ discard block |
||
2547 | 2547 | 'event_espresso' |
2548 | 2548 | ), |
2549 | 2549 | '<br/>', |
2550 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2550 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2551 | 2551 | ), |
2552 | 2552 | __FILE__, |
2553 | 2553 | __FUNCTION__, |
@@ -2578,17 +2578,17 @@ discard block |
||
2578 | 2578 | * @return \EE_Payment |
2579 | 2579 | * @throws \EE_Error |
2580 | 2580 | */ |
2581 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2581 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2582 | 2582 | try { |
2583 | 2583 | $request_data = \EE_Registry::instance()->REQ->params(); |
2584 | 2584 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2585 | 2585 | $this->set_handle_IPN_in_this_request( |
2586 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2586 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2587 | 2587 | ); |
2588 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2588 | + if ($this->handle_IPN_in_this_request()) { |
|
2589 | 2589 | // get payment details and process results |
2590 | 2590 | /** @type EE_Payment_Processor $payment_processor */ |
2591 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2591 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2592 | 2592 | $payment = $payment_processor->process_ipn( |
2593 | 2593 | $request_data, |
2594 | 2594 | $this->checkout->transaction, |
@@ -2601,14 +2601,14 @@ discard block |
||
2601 | 2601 | $payment = $this->checkout->transaction->last_payment(); |
2602 | 2602 | //$payment_source = 'last_payment'; |
2603 | 2603 | } |
2604 | - } catch ( Exception $e ) { |
|
2604 | + } catch (Exception $e) { |
|
2605 | 2605 | // let's just eat the exception and try to move on using any previously set payment info |
2606 | 2606 | $payment = $this->checkout->transaction->last_payment(); |
2607 | 2607 | //$payment_source = 'last_payment after Exception'; |
2608 | 2608 | // but if we STILL don't have a payment object |
2609 | - if ( ! $payment instanceof EE_Payment ) { |
|
2609 | + if ( ! $payment instanceof EE_Payment) { |
|
2610 | 2610 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2611 | - $this->_handle_payment_processor_exception( $e ); |
|
2611 | + $this->_handle_payment_processor_exception($e); |
|
2612 | 2612 | } |
2613 | 2613 | } |
2614 | 2614 | // DEBUG LOG |
@@ -2633,13 +2633,13 @@ discard block |
||
2633 | 2633 | * @return EE_Payment | FALSE |
2634 | 2634 | * @throws \EE_Error |
2635 | 2635 | */ |
2636 | - private function _process_cancelled_payments( $payment = null ) { |
|
2636 | + private function _process_cancelled_payments($payment = null) { |
|
2637 | 2637 | if ( |
2638 | 2638 | $payment instanceof EE_Payment |
2639 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2639 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2640 | 2640 | && $payment->status() === EEM_Payment::status_id_failed |
2641 | 2641 | ) { |
2642 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2642 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2643 | 2643 | } |
2644 | 2644 | return $payment; |
2645 | 2645 | } |
@@ -2656,14 +2656,14 @@ discard block |
||
2656 | 2656 | public function get_transaction_details_for_gateways() { |
2657 | 2657 | $txn_details = array(); |
2658 | 2658 | // ya gotta make a choice man |
2659 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2659 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2660 | 2660 | $txn_details = array( |
2661 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2661 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2662 | 2662 | ); |
2663 | 2663 | } |
2664 | 2664 | // get EE_Payment_Method object |
2665 | 2665 | if ( |
2666 | - empty( $txn_details ) |
|
2666 | + empty($txn_details) |
|
2667 | 2667 | && |
2668 | 2668 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2669 | 2669 | ) { |
@@ -2675,8 +2675,8 @@ discard block |
||
2675 | 2675 | ) |
2676 | 2676 | ); |
2677 | 2677 | } |
2678 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2679 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2678 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2679 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2680 | 2680 | $txn_details = array( |
2681 | 2681 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2682 | 2682 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2687,7 +2687,7 @@ discard block |
||
2687 | 2687 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2688 | 2688 | 'payment_amount' => $this->checkout->amount_owing, |
2689 | 2689 | 'return_url' => $return_url, |
2690 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2690 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2691 | 2691 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2692 | 2692 | array( |
2693 | 2693 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2696,7 +2696,7 @@ discard block |
||
2696 | 2696 | ) |
2697 | 2697 | ); |
2698 | 2698 | } |
2699 | - echo wp_json_encode( $txn_details ); |
|
2699 | + echo wp_json_encode($txn_details); |
|
2700 | 2700 | exit(); |
2701 | 2701 | } |
2702 | 2702 | |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | public function __sleep() |
2714 | 2714 | { |
2715 | 2715 | // remove the reg form and the checkout |
2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2716 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display')); |
|
2717 | 2717 | } |
2718 | 2718 | |
2719 | 2719 |
@@ -17,800 +17,800 @@ discard block |
||
17 | 17 | final class EE_Capabilities extends EE_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * the name of the wp option used to store caps previously initialized |
|
22 | - */ |
|
23 | - const option_name = 'ee_caps_initialized'; |
|
24 | - |
|
25 | - /** |
|
26 | - * instance of EE_Capabilities object |
|
27 | - * |
|
28 | - * @var EE_Capabilities |
|
29 | - */ |
|
30 | - private static $_instance; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * This is a map of caps that correspond to a default WP_Role. |
|
35 | - * Array is indexed by Role and values are ee capabilities. |
|
36 | - * |
|
37 | - * @since 4.5.0 |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - private $_caps_map = array(); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
46 | - * a user depending on context. |
|
47 | - * |
|
48 | - * @var EE_Meta_Capability_Map[] |
|
49 | - */ |
|
50 | - private $_meta_caps = array(); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * singleton method used to instantiate class object |
|
55 | - * |
|
56 | - * @since 4.5.0 |
|
57 | - * |
|
58 | - * @return EE_Capabilities |
|
59 | - */ |
|
60 | - public static function instance() |
|
61 | - { |
|
62 | - //check if instantiated, and if not do so. |
|
63 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
64 | - self::$_instance = new self(); |
|
65 | - } |
|
66 | - return self::$_instance; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * private constructor |
|
72 | - * |
|
73 | - * @since 4.5.0 |
|
74 | - * |
|
75 | - * @return \EE_Capabilities |
|
76 | - */ |
|
77 | - private function __construct() |
|
78 | - { |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
84 | - * |
|
85 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
86 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
87 | - * ensures that they are up to date. |
|
88 | - * |
|
89 | - * |
|
90 | - * @since 4.5.0 |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public function init_caps($reset = false) |
|
94 | - { |
|
95 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
96 | - $this->_caps_map = $this->_init_caps_map(); |
|
97 | - $this->init_role_caps($reset); |
|
98 | - $this->_set_meta_caps(); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * This sets the meta caps property. |
|
105 | - * @since 4.5.0 |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - private function _set_meta_caps() |
|
110 | - { |
|
111 | - //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
112 | - $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
113 | - $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
114 | - //add filter for map_meta_caps but only if models can query. |
|
115 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | - add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * This builds and returns the default meta_caps array only once. |
|
123 | - * |
|
124 | - * @since 4.8.28.rc.012 |
|
125 | - * @return array |
|
126 | - * @throws \EE_Error |
|
127 | - */ |
|
128 | - private function _get_default_meta_caps_array() |
|
129 | - { |
|
130 | - static $default_meta_caps = array(); |
|
131 | - if (empty($default_meta_caps)) { |
|
132 | - $default_meta_caps = array( |
|
133 | - //edits |
|
134 | - new EE_Meta_Capability_Map_Edit( |
|
135 | - 'ee_edit_event', |
|
136 | - array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
137 | - ), |
|
138 | - new EE_Meta_Capability_Map_Edit( |
|
139 | - 'ee_edit_venue', |
|
140 | - array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
141 | - ), |
|
142 | - new EE_Meta_Capability_Map_Edit( |
|
143 | - 'ee_edit_registration', |
|
144 | - array('Registration', '', 'ee_edit_others_registrations', '') |
|
145 | - ), |
|
146 | - new EE_Meta_Capability_Map_Edit( |
|
147 | - 'ee_edit_checkin', |
|
148 | - array('Registration', '', 'ee_edit_others_checkins', '') |
|
149 | - ), |
|
150 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
151 | - 'ee_edit_message', |
|
152 | - array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
153 | - ), |
|
154 | - new EE_Meta_Capability_Map_Edit( |
|
155 | - 'ee_edit_default_ticket', |
|
156 | - array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
157 | - ), |
|
158 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
159 | - 'ee_edit_question', |
|
160 | - array('Question', '', '', 'ee_edit_system_questions') |
|
161 | - ), |
|
162 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
163 | - 'ee_edit_question_group', |
|
164 | - array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
165 | - ), |
|
166 | - new EE_Meta_Capability_Map_Edit( |
|
167 | - 'ee_edit_payment_method', |
|
168 | - array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
169 | - ), |
|
170 | - //reads |
|
171 | - new EE_Meta_Capability_Map_Read( |
|
172 | - 'ee_read_event', |
|
173 | - array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
174 | - ), |
|
175 | - new EE_Meta_Capability_Map_Read( |
|
176 | - 'ee_read_venue', |
|
177 | - array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
178 | - ), |
|
179 | - new EE_Meta_Capability_Map_Read( |
|
180 | - 'ee_read_registration', |
|
181 | - array('Registration', '', '', 'ee_edit_others_registrations') |
|
182 | - ), |
|
183 | - new EE_Meta_Capability_Map_Read( |
|
184 | - 'ee_read_checkin', |
|
185 | - array('Registration', '', '', 'ee_read_others_checkins') |
|
186 | - ), |
|
187 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
188 | - 'ee_read_message', |
|
189 | - array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
190 | - ), |
|
191 | - new EE_Meta_Capability_Map_Read( |
|
192 | - 'ee_read_default_ticket', |
|
193 | - array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
194 | - ), |
|
195 | - new EE_Meta_Capability_Map_Read( |
|
196 | - 'ee_read_payment_method', |
|
197 | - array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
198 | - |
|
199 | - //deletes |
|
200 | - new EE_Meta_Capability_Map_Delete( |
|
201 | - 'ee_delete_event', |
|
202 | - array( |
|
203 | - 'Event', |
|
204 | - 'ee_delete_published_events', |
|
205 | - 'ee_delete_others_events', |
|
206 | - 'ee_delete_private_events', |
|
207 | - ) |
|
208 | - ), |
|
209 | - new EE_Meta_Capability_Map_Delete( |
|
210 | - 'ee_delete_venue', |
|
211 | - array( |
|
212 | - 'Venue', |
|
213 | - 'ee_delete_published_venues', |
|
214 | - 'ee_delete_others_venues', |
|
215 | - 'ee_delete_private_venues', |
|
216 | - ) |
|
217 | - ), |
|
218 | - new EE_Meta_Capability_Map_Delete( |
|
219 | - 'ee_delete_registration', |
|
220 | - array('Registration', '', 'ee_delete_others_registrations', '') |
|
221 | - ), |
|
222 | - new EE_Meta_Capability_Map_Delete( |
|
223 | - 'ee_delete_checkin', |
|
224 | - array('Registration', '', 'ee_delete_others_checkins', '') |
|
225 | - ), |
|
226 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
227 | - 'ee_delete_message', |
|
228 | - array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
229 | - ), |
|
230 | - new EE_Meta_Capability_Map_Delete( |
|
231 | - 'ee_delete_default_ticket', |
|
232 | - array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
233 | - ), |
|
234 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
235 | - 'ee_delete_question', |
|
236 | - array('Question', '', '', 'delete_system_questions') |
|
237 | - ), |
|
238 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
239 | - 'ee_delete_question_group', |
|
240 | - array('Question_Group', '', '', 'delete_system_question_groups') |
|
241 | - ), |
|
242 | - new EE_Meta_Capability_Map_Delete( |
|
243 | - 'ee_delete_payment_method', |
|
244 | - array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
245 | - ), |
|
246 | - ); |
|
247 | - } |
|
248 | - return $default_meta_caps; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
254 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
255 | - * |
|
256 | - * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
257 | - * |
|
258 | - * @since 4.5.0 |
|
259 | - * @see wp-includes/capabilities.php |
|
260 | - * |
|
261 | - * @param array $caps actual users capabilities |
|
262 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
263 | - * @param int $user_id The user id |
|
264 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
265 | - * @return array actual users capabilities |
|
266 | - * @throws EE_Error |
|
267 | - */ |
|
268 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
269 | - { |
|
270 | - if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
271 | - //loop through our _meta_caps array |
|
272 | - foreach ($this->_meta_caps as $meta_map) { |
|
273 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | - continue; |
|
275 | - } |
|
276 | - // don't load models if there is no object ID in the args |
|
277 | - if(!empty($args[0])){ |
|
278 | - $meta_map->ensure_is_model(); |
|
279 | - } |
|
280 | - $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
281 | - } |
|
282 | - } |
|
283 | - return $caps; |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * This sets up and returns the initial capabilities map for Event Espresso |
|
289 | - * |
|
290 | - * @since 4.5.0 |
|
291 | - * |
|
292 | - * @return array |
|
293 | - */ |
|
294 | - private function _init_caps_map() |
|
295 | - { |
|
296 | - $caps = array( |
|
297 | - 'administrator' => array( |
|
298 | - //basic access |
|
299 | - 'ee_read_ee', |
|
300 | - //gateways |
|
301 | - /** |
|
302 | - * note that with payment method capabilities, although we've implemented |
|
303 | - * capability mapping which will be used for accessing payment methods owned by |
|
304 | - * other users. This is not fully implemented yet in the payment method ui. |
|
305 | - * Currently only the "plural" caps are in active use. |
|
306 | - * (Specific payment method caps are in use as well). |
|
307 | - **/ |
|
308 | - 'ee_manage_gateways', |
|
309 | - 'ee_read_payment_method', |
|
310 | - 'ee_read_payment_methods', |
|
311 | - 'ee_read_others_payment_methods', |
|
312 | - 'ee_edit_payment_method', |
|
313 | - 'ee_edit_payment_methods', |
|
314 | - 'ee_edit_others_payment_methods', |
|
315 | - 'ee_delete_payment_method', |
|
316 | - 'ee_delete_payment_methods', |
|
317 | - //events |
|
318 | - 'ee_publish_events', |
|
319 | - 'ee_read_private_events', |
|
320 | - 'ee_read_others_events', |
|
321 | - 'ee_read_event', |
|
322 | - 'ee_read_events', |
|
323 | - 'ee_edit_event', |
|
324 | - 'ee_edit_events', |
|
325 | - 'ee_edit_published_events', |
|
326 | - 'ee_edit_others_events', |
|
327 | - 'ee_edit_private_events', |
|
328 | - 'ee_delete_published_events', |
|
329 | - 'ee_delete_private_events', |
|
330 | - 'ee_delete_event', |
|
331 | - 'ee_delete_events', |
|
332 | - 'ee_delete_others_events', |
|
333 | - //event categories |
|
334 | - 'ee_manage_event_categories', |
|
335 | - 'ee_edit_event_category', |
|
336 | - 'ee_delete_event_category', |
|
337 | - 'ee_assign_event_category', |
|
338 | - //venues |
|
339 | - 'ee_publish_venues', |
|
340 | - 'ee_read_venue', |
|
341 | - 'ee_read_venues', |
|
342 | - 'ee_read_others_venues', |
|
343 | - 'ee_read_private_venues', |
|
344 | - 'ee_edit_venue', |
|
345 | - 'ee_edit_venues', |
|
346 | - 'ee_edit_others_venues', |
|
347 | - 'ee_edit_published_venues', |
|
348 | - 'ee_edit_private_venues', |
|
349 | - 'ee_delete_venue', |
|
350 | - 'ee_delete_venues', |
|
351 | - 'ee_delete_others_venues', |
|
352 | - 'ee_delete_private_venues', |
|
353 | - 'ee_delete_published_venues', |
|
354 | - //venue categories |
|
355 | - 'ee_manage_venue_categories', |
|
356 | - 'ee_edit_venue_category', |
|
357 | - 'ee_delete_venue_category', |
|
358 | - 'ee_assign_venue_category', |
|
359 | - //contacts |
|
360 | - 'ee_read_contact', |
|
361 | - 'ee_read_contacts', |
|
362 | - 'ee_edit_contact', |
|
363 | - 'ee_edit_contacts', |
|
364 | - 'ee_delete_contact', |
|
365 | - 'ee_delete_contacts', |
|
366 | - //registrations |
|
367 | - 'ee_read_registration', |
|
368 | - 'ee_read_registrations', |
|
369 | - 'ee_read_others_registrations', |
|
370 | - 'ee_edit_registration', |
|
371 | - 'ee_edit_registrations', |
|
372 | - 'ee_edit_others_registrations', |
|
373 | - 'ee_delete_registration', |
|
374 | - 'ee_delete_registrations', |
|
375 | - //checkins |
|
376 | - 'ee_read_checkin', |
|
377 | - 'ee_read_others_checkins', |
|
378 | - 'ee_read_checkins', |
|
379 | - 'ee_edit_checkin', |
|
380 | - 'ee_edit_checkins', |
|
381 | - 'ee_edit_others_checkins', |
|
382 | - 'ee_delete_checkin', |
|
383 | - 'ee_delete_checkins', |
|
384 | - 'ee_delete_others_checkins', |
|
385 | - //transactions && payments |
|
386 | - 'ee_read_transaction', |
|
387 | - 'ee_read_transactions', |
|
388 | - 'ee_edit_payments', |
|
389 | - 'ee_delete_payments', |
|
390 | - //messages |
|
391 | - 'ee_read_message', |
|
392 | - 'ee_read_messages', |
|
393 | - 'ee_read_others_messages', |
|
394 | - 'ee_read_global_messages', |
|
395 | - 'ee_edit_global_messages', |
|
396 | - 'ee_edit_message', |
|
397 | - 'ee_edit_messages', |
|
398 | - 'ee_edit_others_messages', |
|
399 | - 'ee_delete_message', |
|
400 | - 'ee_delete_messages', |
|
401 | - 'ee_delete_others_messages', |
|
402 | - 'ee_delete_global_messages', |
|
403 | - 'ee_send_message', |
|
404 | - //tickets |
|
405 | - 'ee_read_default_ticket', |
|
406 | - 'ee_read_default_tickets', |
|
407 | - 'ee_read_others_default_tickets', |
|
408 | - 'ee_edit_default_ticket', |
|
409 | - 'ee_edit_default_tickets', |
|
410 | - 'ee_edit_others_default_tickets', |
|
411 | - 'ee_delete_default_ticket', |
|
412 | - 'ee_delete_default_tickets', |
|
413 | - 'ee_delete_others_default_tickets', |
|
414 | - //prices |
|
415 | - 'ee_edit_default_price', |
|
416 | - 'ee_edit_default_prices', |
|
417 | - 'ee_delete_default_price', |
|
418 | - 'ee_delete_default_prices', |
|
419 | - 'ee_edit_default_price_type', |
|
420 | - 'ee_edit_default_price_types', |
|
421 | - 'ee_delete_default_price_type', |
|
422 | - 'ee_delete_default_price_types', |
|
423 | - 'ee_read_default_prices', |
|
424 | - 'ee_read_default_price_types', |
|
425 | - //registration form |
|
426 | - 'ee_edit_question', |
|
427 | - 'ee_edit_questions', |
|
428 | - 'ee_edit_system_questions', |
|
429 | - 'ee_read_questions', |
|
430 | - 'ee_delete_question', |
|
431 | - 'ee_delete_questions', |
|
432 | - 'ee_edit_question_group', |
|
433 | - 'ee_edit_question_groups', |
|
434 | - 'ee_read_question_groups', |
|
435 | - 'ee_edit_system_question_groups', |
|
436 | - 'ee_delete_question_group', |
|
437 | - 'ee_delete_question_groups', |
|
438 | - //event_type taxonomy |
|
439 | - 'ee_assign_event_type', |
|
440 | - 'ee_manage_event_types', |
|
441 | - 'ee_edit_event_type', |
|
442 | - 'ee_delete_event_type', |
|
443 | - ), |
|
444 | - 'ee_events_administrator' => array( |
|
445 | - //core wp caps |
|
446 | - 'read', |
|
447 | - 'read_private_pages', |
|
448 | - 'read_private_posts', |
|
449 | - 'edit_users', |
|
450 | - 'edit_posts', |
|
451 | - 'edit_pages', |
|
452 | - 'edit_published_posts', |
|
453 | - 'edit_published_pages', |
|
454 | - 'edit_private_pages', |
|
455 | - 'edit_private_posts', |
|
456 | - 'edit_others_posts', |
|
457 | - 'edit_others_pages', |
|
458 | - 'publish_posts', |
|
459 | - 'publish_pages', |
|
460 | - 'delete_posts', |
|
461 | - 'delete_pages', |
|
462 | - 'delete_private_pages', |
|
463 | - 'delete_private_posts', |
|
464 | - 'delete_published_pages', |
|
465 | - 'delete_published_posts', |
|
466 | - 'delete_others_posts', |
|
467 | - 'delete_others_pages', |
|
468 | - 'manage_categories', |
|
469 | - 'manage_links', |
|
470 | - 'moderate_comments', |
|
471 | - 'unfiltered_html', |
|
472 | - 'upload_files', |
|
473 | - 'export', |
|
474 | - 'import', |
|
475 | - 'list_users', |
|
476 | - 'level_1', //required if user with this role shows up in author dropdowns |
|
477 | - //basic ee access |
|
478 | - 'ee_read_ee', |
|
479 | - //events |
|
480 | - 'ee_publish_events', |
|
481 | - 'ee_read_private_events', |
|
482 | - 'ee_read_others_events', |
|
483 | - 'ee_read_event', |
|
484 | - 'ee_read_events', |
|
485 | - 'ee_edit_event', |
|
486 | - 'ee_edit_events', |
|
487 | - 'ee_edit_published_events', |
|
488 | - 'ee_edit_others_events', |
|
489 | - 'ee_edit_private_events', |
|
490 | - 'ee_delete_published_events', |
|
491 | - 'ee_delete_private_events', |
|
492 | - 'ee_delete_event', |
|
493 | - 'ee_delete_events', |
|
494 | - 'ee_delete_others_events', |
|
495 | - //event categories |
|
496 | - 'ee_manage_event_categories', |
|
497 | - 'ee_edit_event_category', |
|
498 | - 'ee_delete_event_category', |
|
499 | - 'ee_assign_event_category', |
|
500 | - //venues |
|
501 | - 'ee_publish_venues', |
|
502 | - 'ee_read_venue', |
|
503 | - 'ee_read_venues', |
|
504 | - 'ee_read_others_venues', |
|
505 | - 'ee_read_private_venues', |
|
506 | - 'ee_edit_venue', |
|
507 | - 'ee_edit_venues', |
|
508 | - 'ee_edit_others_venues', |
|
509 | - 'ee_edit_published_venues', |
|
510 | - 'ee_edit_private_venues', |
|
511 | - 'ee_delete_venue', |
|
512 | - 'ee_delete_venues', |
|
513 | - 'ee_delete_others_venues', |
|
514 | - 'ee_delete_private_venues', |
|
515 | - 'ee_delete_published_venues', |
|
516 | - //venue categories |
|
517 | - 'ee_manage_venue_categories', |
|
518 | - 'ee_edit_venue_category', |
|
519 | - 'ee_delete_venue_category', |
|
520 | - 'ee_assign_venue_category', |
|
521 | - //contacts |
|
522 | - 'ee_read_contact', |
|
523 | - 'ee_read_contacts', |
|
524 | - 'ee_edit_contact', |
|
525 | - 'ee_edit_contacts', |
|
526 | - 'ee_delete_contact', |
|
527 | - 'ee_delete_contacts', |
|
528 | - //registrations |
|
529 | - 'ee_read_registration', |
|
530 | - 'ee_read_registrations', |
|
531 | - 'ee_read_others_registrations', |
|
532 | - 'ee_edit_registration', |
|
533 | - 'ee_edit_registrations', |
|
534 | - 'ee_edit_others_registrations', |
|
535 | - 'ee_delete_registration', |
|
536 | - 'ee_delete_registrations', |
|
537 | - //checkins |
|
538 | - 'ee_read_checkin', |
|
539 | - 'ee_read_others_checkins', |
|
540 | - 'ee_read_checkins', |
|
541 | - 'ee_edit_checkin', |
|
542 | - 'ee_edit_checkins', |
|
543 | - 'ee_edit_others_checkins', |
|
544 | - 'ee_delete_checkin', |
|
545 | - 'ee_delete_checkins', |
|
546 | - 'ee_delete_others_checkins', |
|
547 | - //transactions && payments |
|
548 | - 'ee_read_transaction', |
|
549 | - 'ee_read_transactions', |
|
550 | - 'ee_edit_payments', |
|
551 | - 'ee_delete_payments', |
|
552 | - //messages |
|
553 | - 'ee_read_message', |
|
554 | - 'ee_read_messages', |
|
555 | - 'ee_read_others_messages', |
|
556 | - 'ee_read_global_messages', |
|
557 | - 'ee_edit_global_messages', |
|
558 | - 'ee_edit_message', |
|
559 | - 'ee_edit_messages', |
|
560 | - 'ee_edit_others_messages', |
|
561 | - 'ee_delete_message', |
|
562 | - 'ee_delete_messages', |
|
563 | - 'ee_delete_others_messages', |
|
564 | - 'ee_delete_global_messages', |
|
565 | - 'ee_send_message', |
|
566 | - //tickets |
|
567 | - 'ee_read_default_ticket', |
|
568 | - 'ee_read_default_tickets', |
|
569 | - 'ee_read_others_default_tickets', |
|
570 | - 'ee_edit_default_ticket', |
|
571 | - 'ee_edit_default_tickets', |
|
572 | - 'ee_edit_others_default_tickets', |
|
573 | - 'ee_delete_default_ticket', |
|
574 | - 'ee_delete_default_tickets', |
|
575 | - 'ee_delete_others_default_tickets', |
|
576 | - //prices |
|
577 | - 'ee_edit_default_price', |
|
578 | - 'ee_edit_default_prices', |
|
579 | - 'ee_delete_default_price', |
|
580 | - 'ee_delete_default_prices', |
|
581 | - 'ee_edit_default_price_type', |
|
582 | - 'ee_edit_default_price_types', |
|
583 | - 'ee_delete_default_price_type', |
|
584 | - 'ee_delete_default_price_types', |
|
585 | - 'ee_read_default_prices', |
|
586 | - 'ee_read_default_price_types', |
|
587 | - //registration form |
|
588 | - 'ee_edit_question', |
|
589 | - 'ee_edit_questions', |
|
590 | - 'ee_edit_system_questions', |
|
591 | - 'ee_read_questions', |
|
592 | - 'ee_delete_question', |
|
593 | - 'ee_delete_questions', |
|
594 | - 'ee_edit_question_group', |
|
595 | - 'ee_edit_question_groups', |
|
596 | - 'ee_read_question_groups', |
|
597 | - 'ee_edit_system_question_groups', |
|
598 | - 'ee_delete_question_group', |
|
599 | - 'ee_delete_question_groups', |
|
600 | - //event_type taxonomy |
|
601 | - 'ee_assign_event_type', |
|
602 | - 'ee_manage_event_types', |
|
603 | - 'ee_edit_event_type', |
|
604 | - 'ee_delete_event_type', |
|
605 | - ) |
|
606 | - ); |
|
607 | - $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
608 | - return $caps; |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - /** |
|
613 | - * This adds all the default caps to roles as registered in the _caps_map property. |
|
614 | - * |
|
615 | - * @since 4.5.0 |
|
616 | - * |
|
617 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
618 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
619 | - * and ensures that they are up to date. |
|
620 | - * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
621 | - * up. Note that this should ONLY be called on activation hook or some other one-time |
|
622 | - * task otherwise the caps will be added on every request. |
|
623 | - * |
|
624 | - * @return void |
|
625 | - */ |
|
626 | - public function init_role_caps($reset = false, $custom_map = array()) |
|
627 | - { |
|
628 | - $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
629 | - //first let's determine if these caps have already been set. |
|
630 | - $caps_set_before = get_option(self::option_name, array()); |
|
631 | - //if not reset, see what caps are new for each role. if they're new, add them. |
|
632 | - foreach ($caps_map as $role => $caps_for_role) { |
|
633 | - foreach ($caps_for_role as $cap) { |
|
634 | - //first check we haven't already added this cap before, or it's a reset |
|
635 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
636 | - if ($this->add_cap_to_role($role, $cap)) { |
|
637 | - $caps_set_before[ $role ][] = $cap; |
|
638 | - } |
|
639 | - } |
|
640 | - } |
|
641 | - } |
|
642 | - //now let's just save the cap that has been set. |
|
643 | - update_option(self::option_name, $caps_set_before); |
|
644 | - do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
650 | - * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
651 | - * this is a wrapper for $wp_role->add_cap() |
|
652 | - * |
|
653 | - * @see wp-includes/capabilities.php |
|
654 | - * |
|
655 | - * @since 4.5.0 |
|
656 | - * |
|
657 | - * @param string $role A WordPress role the capability is being added to |
|
658 | - * @param string $cap The capability being added to the role |
|
659 | - * @param bool $grant Whether to grant access to this cap on this role. |
|
660 | - * |
|
661 | - * @return bool |
|
662 | - */ |
|
663 | - public function add_cap_to_role($role, $cap, $grant = true) |
|
664 | - { |
|
665 | - $role_object = get_role($role); |
|
666 | - //if the role isn't available then we create it. |
|
667 | - if (! $role_object instanceof WP_Role) { |
|
668 | - //if a plugin wants to create a specific role name then they should create the role before |
|
669 | - //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
670 | - // - removes any `ee_` namespacing from the start of the slug. |
|
671 | - // - replaces `_` with ` ` (empty space). |
|
672 | - // - sentence case on the resulting string. |
|
673 | - $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
674 | - $role_object = add_role($role, $role_label); |
|
675 | - } |
|
676 | - if ($role_object instanceof WP_Role) { |
|
677 | - $role_object->add_cap($cap, $grant); |
|
678 | - return true; |
|
679 | - } |
|
680 | - return false; |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - /** |
|
685 | - * Functions similarly to add_cap_to_role except removes cap from given role. |
|
686 | - * Wrapper for $wp_role->remove_cap() |
|
687 | - * |
|
688 | - * @see wp-includes/capabilities.php |
|
689 | - * @since 4.5.0 |
|
690 | - * |
|
691 | - * @param string $role A WordPress role the capability is being removed from. |
|
692 | - * @param string $cap The capability being removed |
|
693 | - * |
|
694 | - * @return void |
|
695 | - */ |
|
696 | - public function remove_cap_from_role($role, $cap) |
|
697 | - { |
|
698 | - $role = get_role($role); |
|
699 | - if ($role instanceof WP_Role) { |
|
700 | - $role->remove_cap($cap); |
|
701 | - } |
|
702 | - } |
|
703 | - |
|
704 | - |
|
705 | - /** |
|
706 | - * Wrapper for the native WP current_user_can() method. |
|
707 | - * This is provided as a handy method for a couple things: |
|
708 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
709 | - * write those filters wherever current_user_can is called). |
|
710 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
711 | - * |
|
712 | - * @since 4.5.0 |
|
713 | - * |
|
714 | - * @param string $cap The cap being checked. |
|
715 | - * @param string $context The context where the current_user_can is being called from. |
|
716 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
717 | - * filters. |
|
718 | - * |
|
719 | - * @return bool Whether user can or not. |
|
720 | - */ |
|
721 | - public function current_user_can($cap, $context, $id = 0) |
|
722 | - { |
|
723 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
724 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
725 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
726 | - $id); |
|
727 | - return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
733 | - * |
|
734 | - * @param int|WP_User $user Either the user_id or a WP_User object |
|
735 | - * @param string $cap The capability string being checked |
|
736 | - * @param string $context The context where the user_can is being called from (used in filters). |
|
737 | - * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
738 | - * filters) |
|
739 | - * |
|
740 | - * @return bool Whether user can or not. |
|
741 | - */ |
|
742 | - public function user_can($user, $cap, $context, $id = 0) |
|
743 | - { |
|
744 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
745 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
746 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
747 | - $id); |
|
748 | - return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * Wrapper for the native WP current_user_can_for_blog() method. |
|
754 | - * This is provided as a handy method for a couple things: |
|
755 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
756 | - * write those filters wherever current_user_can is called). |
|
757 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
758 | - * |
|
759 | - * @since 4.5.0 |
|
760 | - * |
|
761 | - * @param int $blog_id The blog id that is being checked for. |
|
762 | - * @param string $cap The cap being checked. |
|
763 | - * @param string $context The context where the current_user_can is being called from. |
|
764 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
765 | - * filters. |
|
766 | - * |
|
767 | - * @return bool Whether user can or not. |
|
768 | - */ |
|
769 | - public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
770 | - { |
|
771 | - $user_can = ! empty($id) |
|
772 | - ? current_user_can_for_blog($blog_id, $cap, $id) |
|
773 | - : current_user_can($blog_id, $cap); |
|
774 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
775 | - $user_can = apply_filters( |
|
776 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
777 | - $user_can, |
|
778 | - $blog_id, |
|
779 | - $cap, |
|
780 | - $id |
|
781 | - ); |
|
782 | - $user_can = apply_filters( |
|
783 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
784 | - $user_can, |
|
785 | - $context, |
|
786 | - $blog_id, |
|
787 | - $cap, |
|
788 | - $id |
|
789 | - ); |
|
790 | - return $user_can; |
|
791 | - } |
|
792 | - |
|
793 | - |
|
794 | - /** |
|
795 | - * This helper method just returns an array of registered EE capabilities. |
|
796 | - * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
797 | - * role. |
|
798 | - * |
|
799 | - * @since 4.5.0 |
|
800 | - * |
|
801 | - * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
802 | - * for the given role are returned. |
|
803 | - * |
|
804 | - * @return array |
|
805 | - */ |
|
806 | - public function get_ee_capabilities($role = 'administrator') |
|
807 | - { |
|
808 | - $capabilities = $this->_init_caps_map(); |
|
809 | - if (empty($role)) { |
|
810 | - return $capabilities; |
|
811 | - } |
|
812 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
813 | - } |
|
20 | + /** |
|
21 | + * the name of the wp option used to store caps previously initialized |
|
22 | + */ |
|
23 | + const option_name = 'ee_caps_initialized'; |
|
24 | + |
|
25 | + /** |
|
26 | + * instance of EE_Capabilities object |
|
27 | + * |
|
28 | + * @var EE_Capabilities |
|
29 | + */ |
|
30 | + private static $_instance; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * This is a map of caps that correspond to a default WP_Role. |
|
35 | + * Array is indexed by Role and values are ee capabilities. |
|
36 | + * |
|
37 | + * @since 4.5.0 |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + private $_caps_map = array(); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
46 | + * a user depending on context. |
|
47 | + * |
|
48 | + * @var EE_Meta_Capability_Map[] |
|
49 | + */ |
|
50 | + private $_meta_caps = array(); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * singleton method used to instantiate class object |
|
55 | + * |
|
56 | + * @since 4.5.0 |
|
57 | + * |
|
58 | + * @return EE_Capabilities |
|
59 | + */ |
|
60 | + public static function instance() |
|
61 | + { |
|
62 | + //check if instantiated, and if not do so. |
|
63 | + if (! self::$_instance instanceof EE_Capabilities) { |
|
64 | + self::$_instance = new self(); |
|
65 | + } |
|
66 | + return self::$_instance; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * private constructor |
|
72 | + * |
|
73 | + * @since 4.5.0 |
|
74 | + * |
|
75 | + * @return \EE_Capabilities |
|
76 | + */ |
|
77 | + private function __construct() |
|
78 | + { |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
84 | + * |
|
85 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
86 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
87 | + * ensures that they are up to date. |
|
88 | + * |
|
89 | + * |
|
90 | + * @since 4.5.0 |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public function init_caps($reset = false) |
|
94 | + { |
|
95 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
96 | + $this->_caps_map = $this->_init_caps_map(); |
|
97 | + $this->init_role_caps($reset); |
|
98 | + $this->_set_meta_caps(); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * This sets the meta caps property. |
|
105 | + * @since 4.5.0 |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + private function _set_meta_caps() |
|
110 | + { |
|
111 | + //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
112 | + $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
113 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
114 | + //add filter for map_meta_caps but only if models can query. |
|
115 | + if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * This builds and returns the default meta_caps array only once. |
|
123 | + * |
|
124 | + * @since 4.8.28.rc.012 |
|
125 | + * @return array |
|
126 | + * @throws \EE_Error |
|
127 | + */ |
|
128 | + private function _get_default_meta_caps_array() |
|
129 | + { |
|
130 | + static $default_meta_caps = array(); |
|
131 | + if (empty($default_meta_caps)) { |
|
132 | + $default_meta_caps = array( |
|
133 | + //edits |
|
134 | + new EE_Meta_Capability_Map_Edit( |
|
135 | + 'ee_edit_event', |
|
136 | + array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
137 | + ), |
|
138 | + new EE_Meta_Capability_Map_Edit( |
|
139 | + 'ee_edit_venue', |
|
140 | + array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
141 | + ), |
|
142 | + new EE_Meta_Capability_Map_Edit( |
|
143 | + 'ee_edit_registration', |
|
144 | + array('Registration', '', 'ee_edit_others_registrations', '') |
|
145 | + ), |
|
146 | + new EE_Meta_Capability_Map_Edit( |
|
147 | + 'ee_edit_checkin', |
|
148 | + array('Registration', '', 'ee_edit_others_checkins', '') |
|
149 | + ), |
|
150 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
151 | + 'ee_edit_message', |
|
152 | + array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
153 | + ), |
|
154 | + new EE_Meta_Capability_Map_Edit( |
|
155 | + 'ee_edit_default_ticket', |
|
156 | + array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
157 | + ), |
|
158 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
159 | + 'ee_edit_question', |
|
160 | + array('Question', '', '', 'ee_edit_system_questions') |
|
161 | + ), |
|
162 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
163 | + 'ee_edit_question_group', |
|
164 | + array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
165 | + ), |
|
166 | + new EE_Meta_Capability_Map_Edit( |
|
167 | + 'ee_edit_payment_method', |
|
168 | + array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
169 | + ), |
|
170 | + //reads |
|
171 | + new EE_Meta_Capability_Map_Read( |
|
172 | + 'ee_read_event', |
|
173 | + array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
174 | + ), |
|
175 | + new EE_Meta_Capability_Map_Read( |
|
176 | + 'ee_read_venue', |
|
177 | + array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
178 | + ), |
|
179 | + new EE_Meta_Capability_Map_Read( |
|
180 | + 'ee_read_registration', |
|
181 | + array('Registration', '', '', 'ee_edit_others_registrations') |
|
182 | + ), |
|
183 | + new EE_Meta_Capability_Map_Read( |
|
184 | + 'ee_read_checkin', |
|
185 | + array('Registration', '', '', 'ee_read_others_checkins') |
|
186 | + ), |
|
187 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
188 | + 'ee_read_message', |
|
189 | + array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
190 | + ), |
|
191 | + new EE_Meta_Capability_Map_Read( |
|
192 | + 'ee_read_default_ticket', |
|
193 | + array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
194 | + ), |
|
195 | + new EE_Meta_Capability_Map_Read( |
|
196 | + 'ee_read_payment_method', |
|
197 | + array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
198 | + |
|
199 | + //deletes |
|
200 | + new EE_Meta_Capability_Map_Delete( |
|
201 | + 'ee_delete_event', |
|
202 | + array( |
|
203 | + 'Event', |
|
204 | + 'ee_delete_published_events', |
|
205 | + 'ee_delete_others_events', |
|
206 | + 'ee_delete_private_events', |
|
207 | + ) |
|
208 | + ), |
|
209 | + new EE_Meta_Capability_Map_Delete( |
|
210 | + 'ee_delete_venue', |
|
211 | + array( |
|
212 | + 'Venue', |
|
213 | + 'ee_delete_published_venues', |
|
214 | + 'ee_delete_others_venues', |
|
215 | + 'ee_delete_private_venues', |
|
216 | + ) |
|
217 | + ), |
|
218 | + new EE_Meta_Capability_Map_Delete( |
|
219 | + 'ee_delete_registration', |
|
220 | + array('Registration', '', 'ee_delete_others_registrations', '') |
|
221 | + ), |
|
222 | + new EE_Meta_Capability_Map_Delete( |
|
223 | + 'ee_delete_checkin', |
|
224 | + array('Registration', '', 'ee_delete_others_checkins', '') |
|
225 | + ), |
|
226 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
227 | + 'ee_delete_message', |
|
228 | + array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
229 | + ), |
|
230 | + new EE_Meta_Capability_Map_Delete( |
|
231 | + 'ee_delete_default_ticket', |
|
232 | + array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
233 | + ), |
|
234 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
235 | + 'ee_delete_question', |
|
236 | + array('Question', '', '', 'delete_system_questions') |
|
237 | + ), |
|
238 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
239 | + 'ee_delete_question_group', |
|
240 | + array('Question_Group', '', '', 'delete_system_question_groups') |
|
241 | + ), |
|
242 | + new EE_Meta_Capability_Map_Delete( |
|
243 | + 'ee_delete_payment_method', |
|
244 | + array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
245 | + ), |
|
246 | + ); |
|
247 | + } |
|
248 | + return $default_meta_caps; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
254 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
255 | + * |
|
256 | + * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
257 | + * |
|
258 | + * @since 4.5.0 |
|
259 | + * @see wp-includes/capabilities.php |
|
260 | + * |
|
261 | + * @param array $caps actual users capabilities |
|
262 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
263 | + * @param int $user_id The user id |
|
264 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
265 | + * @return array actual users capabilities |
|
266 | + * @throws EE_Error |
|
267 | + */ |
|
268 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
269 | + { |
|
270 | + if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
271 | + //loop through our _meta_caps array |
|
272 | + foreach ($this->_meta_caps as $meta_map) { |
|
273 | + if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | + continue; |
|
275 | + } |
|
276 | + // don't load models if there is no object ID in the args |
|
277 | + if(!empty($args[0])){ |
|
278 | + $meta_map->ensure_is_model(); |
|
279 | + } |
|
280 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
281 | + } |
|
282 | + } |
|
283 | + return $caps; |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * This sets up and returns the initial capabilities map for Event Espresso |
|
289 | + * |
|
290 | + * @since 4.5.0 |
|
291 | + * |
|
292 | + * @return array |
|
293 | + */ |
|
294 | + private function _init_caps_map() |
|
295 | + { |
|
296 | + $caps = array( |
|
297 | + 'administrator' => array( |
|
298 | + //basic access |
|
299 | + 'ee_read_ee', |
|
300 | + //gateways |
|
301 | + /** |
|
302 | + * note that with payment method capabilities, although we've implemented |
|
303 | + * capability mapping which will be used for accessing payment methods owned by |
|
304 | + * other users. This is not fully implemented yet in the payment method ui. |
|
305 | + * Currently only the "plural" caps are in active use. |
|
306 | + * (Specific payment method caps are in use as well). |
|
307 | + **/ |
|
308 | + 'ee_manage_gateways', |
|
309 | + 'ee_read_payment_method', |
|
310 | + 'ee_read_payment_methods', |
|
311 | + 'ee_read_others_payment_methods', |
|
312 | + 'ee_edit_payment_method', |
|
313 | + 'ee_edit_payment_methods', |
|
314 | + 'ee_edit_others_payment_methods', |
|
315 | + 'ee_delete_payment_method', |
|
316 | + 'ee_delete_payment_methods', |
|
317 | + //events |
|
318 | + 'ee_publish_events', |
|
319 | + 'ee_read_private_events', |
|
320 | + 'ee_read_others_events', |
|
321 | + 'ee_read_event', |
|
322 | + 'ee_read_events', |
|
323 | + 'ee_edit_event', |
|
324 | + 'ee_edit_events', |
|
325 | + 'ee_edit_published_events', |
|
326 | + 'ee_edit_others_events', |
|
327 | + 'ee_edit_private_events', |
|
328 | + 'ee_delete_published_events', |
|
329 | + 'ee_delete_private_events', |
|
330 | + 'ee_delete_event', |
|
331 | + 'ee_delete_events', |
|
332 | + 'ee_delete_others_events', |
|
333 | + //event categories |
|
334 | + 'ee_manage_event_categories', |
|
335 | + 'ee_edit_event_category', |
|
336 | + 'ee_delete_event_category', |
|
337 | + 'ee_assign_event_category', |
|
338 | + //venues |
|
339 | + 'ee_publish_venues', |
|
340 | + 'ee_read_venue', |
|
341 | + 'ee_read_venues', |
|
342 | + 'ee_read_others_venues', |
|
343 | + 'ee_read_private_venues', |
|
344 | + 'ee_edit_venue', |
|
345 | + 'ee_edit_venues', |
|
346 | + 'ee_edit_others_venues', |
|
347 | + 'ee_edit_published_venues', |
|
348 | + 'ee_edit_private_venues', |
|
349 | + 'ee_delete_venue', |
|
350 | + 'ee_delete_venues', |
|
351 | + 'ee_delete_others_venues', |
|
352 | + 'ee_delete_private_venues', |
|
353 | + 'ee_delete_published_venues', |
|
354 | + //venue categories |
|
355 | + 'ee_manage_venue_categories', |
|
356 | + 'ee_edit_venue_category', |
|
357 | + 'ee_delete_venue_category', |
|
358 | + 'ee_assign_venue_category', |
|
359 | + //contacts |
|
360 | + 'ee_read_contact', |
|
361 | + 'ee_read_contacts', |
|
362 | + 'ee_edit_contact', |
|
363 | + 'ee_edit_contacts', |
|
364 | + 'ee_delete_contact', |
|
365 | + 'ee_delete_contacts', |
|
366 | + //registrations |
|
367 | + 'ee_read_registration', |
|
368 | + 'ee_read_registrations', |
|
369 | + 'ee_read_others_registrations', |
|
370 | + 'ee_edit_registration', |
|
371 | + 'ee_edit_registrations', |
|
372 | + 'ee_edit_others_registrations', |
|
373 | + 'ee_delete_registration', |
|
374 | + 'ee_delete_registrations', |
|
375 | + //checkins |
|
376 | + 'ee_read_checkin', |
|
377 | + 'ee_read_others_checkins', |
|
378 | + 'ee_read_checkins', |
|
379 | + 'ee_edit_checkin', |
|
380 | + 'ee_edit_checkins', |
|
381 | + 'ee_edit_others_checkins', |
|
382 | + 'ee_delete_checkin', |
|
383 | + 'ee_delete_checkins', |
|
384 | + 'ee_delete_others_checkins', |
|
385 | + //transactions && payments |
|
386 | + 'ee_read_transaction', |
|
387 | + 'ee_read_transactions', |
|
388 | + 'ee_edit_payments', |
|
389 | + 'ee_delete_payments', |
|
390 | + //messages |
|
391 | + 'ee_read_message', |
|
392 | + 'ee_read_messages', |
|
393 | + 'ee_read_others_messages', |
|
394 | + 'ee_read_global_messages', |
|
395 | + 'ee_edit_global_messages', |
|
396 | + 'ee_edit_message', |
|
397 | + 'ee_edit_messages', |
|
398 | + 'ee_edit_others_messages', |
|
399 | + 'ee_delete_message', |
|
400 | + 'ee_delete_messages', |
|
401 | + 'ee_delete_others_messages', |
|
402 | + 'ee_delete_global_messages', |
|
403 | + 'ee_send_message', |
|
404 | + //tickets |
|
405 | + 'ee_read_default_ticket', |
|
406 | + 'ee_read_default_tickets', |
|
407 | + 'ee_read_others_default_tickets', |
|
408 | + 'ee_edit_default_ticket', |
|
409 | + 'ee_edit_default_tickets', |
|
410 | + 'ee_edit_others_default_tickets', |
|
411 | + 'ee_delete_default_ticket', |
|
412 | + 'ee_delete_default_tickets', |
|
413 | + 'ee_delete_others_default_tickets', |
|
414 | + //prices |
|
415 | + 'ee_edit_default_price', |
|
416 | + 'ee_edit_default_prices', |
|
417 | + 'ee_delete_default_price', |
|
418 | + 'ee_delete_default_prices', |
|
419 | + 'ee_edit_default_price_type', |
|
420 | + 'ee_edit_default_price_types', |
|
421 | + 'ee_delete_default_price_type', |
|
422 | + 'ee_delete_default_price_types', |
|
423 | + 'ee_read_default_prices', |
|
424 | + 'ee_read_default_price_types', |
|
425 | + //registration form |
|
426 | + 'ee_edit_question', |
|
427 | + 'ee_edit_questions', |
|
428 | + 'ee_edit_system_questions', |
|
429 | + 'ee_read_questions', |
|
430 | + 'ee_delete_question', |
|
431 | + 'ee_delete_questions', |
|
432 | + 'ee_edit_question_group', |
|
433 | + 'ee_edit_question_groups', |
|
434 | + 'ee_read_question_groups', |
|
435 | + 'ee_edit_system_question_groups', |
|
436 | + 'ee_delete_question_group', |
|
437 | + 'ee_delete_question_groups', |
|
438 | + //event_type taxonomy |
|
439 | + 'ee_assign_event_type', |
|
440 | + 'ee_manage_event_types', |
|
441 | + 'ee_edit_event_type', |
|
442 | + 'ee_delete_event_type', |
|
443 | + ), |
|
444 | + 'ee_events_administrator' => array( |
|
445 | + //core wp caps |
|
446 | + 'read', |
|
447 | + 'read_private_pages', |
|
448 | + 'read_private_posts', |
|
449 | + 'edit_users', |
|
450 | + 'edit_posts', |
|
451 | + 'edit_pages', |
|
452 | + 'edit_published_posts', |
|
453 | + 'edit_published_pages', |
|
454 | + 'edit_private_pages', |
|
455 | + 'edit_private_posts', |
|
456 | + 'edit_others_posts', |
|
457 | + 'edit_others_pages', |
|
458 | + 'publish_posts', |
|
459 | + 'publish_pages', |
|
460 | + 'delete_posts', |
|
461 | + 'delete_pages', |
|
462 | + 'delete_private_pages', |
|
463 | + 'delete_private_posts', |
|
464 | + 'delete_published_pages', |
|
465 | + 'delete_published_posts', |
|
466 | + 'delete_others_posts', |
|
467 | + 'delete_others_pages', |
|
468 | + 'manage_categories', |
|
469 | + 'manage_links', |
|
470 | + 'moderate_comments', |
|
471 | + 'unfiltered_html', |
|
472 | + 'upload_files', |
|
473 | + 'export', |
|
474 | + 'import', |
|
475 | + 'list_users', |
|
476 | + 'level_1', //required if user with this role shows up in author dropdowns |
|
477 | + //basic ee access |
|
478 | + 'ee_read_ee', |
|
479 | + //events |
|
480 | + 'ee_publish_events', |
|
481 | + 'ee_read_private_events', |
|
482 | + 'ee_read_others_events', |
|
483 | + 'ee_read_event', |
|
484 | + 'ee_read_events', |
|
485 | + 'ee_edit_event', |
|
486 | + 'ee_edit_events', |
|
487 | + 'ee_edit_published_events', |
|
488 | + 'ee_edit_others_events', |
|
489 | + 'ee_edit_private_events', |
|
490 | + 'ee_delete_published_events', |
|
491 | + 'ee_delete_private_events', |
|
492 | + 'ee_delete_event', |
|
493 | + 'ee_delete_events', |
|
494 | + 'ee_delete_others_events', |
|
495 | + //event categories |
|
496 | + 'ee_manage_event_categories', |
|
497 | + 'ee_edit_event_category', |
|
498 | + 'ee_delete_event_category', |
|
499 | + 'ee_assign_event_category', |
|
500 | + //venues |
|
501 | + 'ee_publish_venues', |
|
502 | + 'ee_read_venue', |
|
503 | + 'ee_read_venues', |
|
504 | + 'ee_read_others_venues', |
|
505 | + 'ee_read_private_venues', |
|
506 | + 'ee_edit_venue', |
|
507 | + 'ee_edit_venues', |
|
508 | + 'ee_edit_others_venues', |
|
509 | + 'ee_edit_published_venues', |
|
510 | + 'ee_edit_private_venues', |
|
511 | + 'ee_delete_venue', |
|
512 | + 'ee_delete_venues', |
|
513 | + 'ee_delete_others_venues', |
|
514 | + 'ee_delete_private_venues', |
|
515 | + 'ee_delete_published_venues', |
|
516 | + //venue categories |
|
517 | + 'ee_manage_venue_categories', |
|
518 | + 'ee_edit_venue_category', |
|
519 | + 'ee_delete_venue_category', |
|
520 | + 'ee_assign_venue_category', |
|
521 | + //contacts |
|
522 | + 'ee_read_contact', |
|
523 | + 'ee_read_contacts', |
|
524 | + 'ee_edit_contact', |
|
525 | + 'ee_edit_contacts', |
|
526 | + 'ee_delete_contact', |
|
527 | + 'ee_delete_contacts', |
|
528 | + //registrations |
|
529 | + 'ee_read_registration', |
|
530 | + 'ee_read_registrations', |
|
531 | + 'ee_read_others_registrations', |
|
532 | + 'ee_edit_registration', |
|
533 | + 'ee_edit_registrations', |
|
534 | + 'ee_edit_others_registrations', |
|
535 | + 'ee_delete_registration', |
|
536 | + 'ee_delete_registrations', |
|
537 | + //checkins |
|
538 | + 'ee_read_checkin', |
|
539 | + 'ee_read_others_checkins', |
|
540 | + 'ee_read_checkins', |
|
541 | + 'ee_edit_checkin', |
|
542 | + 'ee_edit_checkins', |
|
543 | + 'ee_edit_others_checkins', |
|
544 | + 'ee_delete_checkin', |
|
545 | + 'ee_delete_checkins', |
|
546 | + 'ee_delete_others_checkins', |
|
547 | + //transactions && payments |
|
548 | + 'ee_read_transaction', |
|
549 | + 'ee_read_transactions', |
|
550 | + 'ee_edit_payments', |
|
551 | + 'ee_delete_payments', |
|
552 | + //messages |
|
553 | + 'ee_read_message', |
|
554 | + 'ee_read_messages', |
|
555 | + 'ee_read_others_messages', |
|
556 | + 'ee_read_global_messages', |
|
557 | + 'ee_edit_global_messages', |
|
558 | + 'ee_edit_message', |
|
559 | + 'ee_edit_messages', |
|
560 | + 'ee_edit_others_messages', |
|
561 | + 'ee_delete_message', |
|
562 | + 'ee_delete_messages', |
|
563 | + 'ee_delete_others_messages', |
|
564 | + 'ee_delete_global_messages', |
|
565 | + 'ee_send_message', |
|
566 | + //tickets |
|
567 | + 'ee_read_default_ticket', |
|
568 | + 'ee_read_default_tickets', |
|
569 | + 'ee_read_others_default_tickets', |
|
570 | + 'ee_edit_default_ticket', |
|
571 | + 'ee_edit_default_tickets', |
|
572 | + 'ee_edit_others_default_tickets', |
|
573 | + 'ee_delete_default_ticket', |
|
574 | + 'ee_delete_default_tickets', |
|
575 | + 'ee_delete_others_default_tickets', |
|
576 | + //prices |
|
577 | + 'ee_edit_default_price', |
|
578 | + 'ee_edit_default_prices', |
|
579 | + 'ee_delete_default_price', |
|
580 | + 'ee_delete_default_prices', |
|
581 | + 'ee_edit_default_price_type', |
|
582 | + 'ee_edit_default_price_types', |
|
583 | + 'ee_delete_default_price_type', |
|
584 | + 'ee_delete_default_price_types', |
|
585 | + 'ee_read_default_prices', |
|
586 | + 'ee_read_default_price_types', |
|
587 | + //registration form |
|
588 | + 'ee_edit_question', |
|
589 | + 'ee_edit_questions', |
|
590 | + 'ee_edit_system_questions', |
|
591 | + 'ee_read_questions', |
|
592 | + 'ee_delete_question', |
|
593 | + 'ee_delete_questions', |
|
594 | + 'ee_edit_question_group', |
|
595 | + 'ee_edit_question_groups', |
|
596 | + 'ee_read_question_groups', |
|
597 | + 'ee_edit_system_question_groups', |
|
598 | + 'ee_delete_question_group', |
|
599 | + 'ee_delete_question_groups', |
|
600 | + //event_type taxonomy |
|
601 | + 'ee_assign_event_type', |
|
602 | + 'ee_manage_event_types', |
|
603 | + 'ee_edit_event_type', |
|
604 | + 'ee_delete_event_type', |
|
605 | + ) |
|
606 | + ); |
|
607 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
608 | + return $caps; |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + /** |
|
613 | + * This adds all the default caps to roles as registered in the _caps_map property. |
|
614 | + * |
|
615 | + * @since 4.5.0 |
|
616 | + * |
|
617 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
618 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
619 | + * and ensures that they are up to date. |
|
620 | + * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
621 | + * up. Note that this should ONLY be called on activation hook or some other one-time |
|
622 | + * task otherwise the caps will be added on every request. |
|
623 | + * |
|
624 | + * @return void |
|
625 | + */ |
|
626 | + public function init_role_caps($reset = false, $custom_map = array()) |
|
627 | + { |
|
628 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
629 | + //first let's determine if these caps have already been set. |
|
630 | + $caps_set_before = get_option(self::option_name, array()); |
|
631 | + //if not reset, see what caps are new for each role. if they're new, add them. |
|
632 | + foreach ($caps_map as $role => $caps_for_role) { |
|
633 | + foreach ($caps_for_role as $cap) { |
|
634 | + //first check we haven't already added this cap before, or it's a reset |
|
635 | + if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
636 | + if ($this->add_cap_to_role($role, $cap)) { |
|
637 | + $caps_set_before[ $role ][] = $cap; |
|
638 | + } |
|
639 | + } |
|
640 | + } |
|
641 | + } |
|
642 | + //now let's just save the cap that has been set. |
|
643 | + update_option(self::option_name, $caps_set_before); |
|
644 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
650 | + * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
651 | + * this is a wrapper for $wp_role->add_cap() |
|
652 | + * |
|
653 | + * @see wp-includes/capabilities.php |
|
654 | + * |
|
655 | + * @since 4.5.0 |
|
656 | + * |
|
657 | + * @param string $role A WordPress role the capability is being added to |
|
658 | + * @param string $cap The capability being added to the role |
|
659 | + * @param bool $grant Whether to grant access to this cap on this role. |
|
660 | + * |
|
661 | + * @return bool |
|
662 | + */ |
|
663 | + public function add_cap_to_role($role, $cap, $grant = true) |
|
664 | + { |
|
665 | + $role_object = get_role($role); |
|
666 | + //if the role isn't available then we create it. |
|
667 | + if (! $role_object instanceof WP_Role) { |
|
668 | + //if a plugin wants to create a specific role name then they should create the role before |
|
669 | + //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
670 | + // - removes any `ee_` namespacing from the start of the slug. |
|
671 | + // - replaces `_` with ` ` (empty space). |
|
672 | + // - sentence case on the resulting string. |
|
673 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
674 | + $role_object = add_role($role, $role_label); |
|
675 | + } |
|
676 | + if ($role_object instanceof WP_Role) { |
|
677 | + $role_object->add_cap($cap, $grant); |
|
678 | + return true; |
|
679 | + } |
|
680 | + return false; |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + /** |
|
685 | + * Functions similarly to add_cap_to_role except removes cap from given role. |
|
686 | + * Wrapper for $wp_role->remove_cap() |
|
687 | + * |
|
688 | + * @see wp-includes/capabilities.php |
|
689 | + * @since 4.5.0 |
|
690 | + * |
|
691 | + * @param string $role A WordPress role the capability is being removed from. |
|
692 | + * @param string $cap The capability being removed |
|
693 | + * |
|
694 | + * @return void |
|
695 | + */ |
|
696 | + public function remove_cap_from_role($role, $cap) |
|
697 | + { |
|
698 | + $role = get_role($role); |
|
699 | + if ($role instanceof WP_Role) { |
|
700 | + $role->remove_cap($cap); |
|
701 | + } |
|
702 | + } |
|
703 | + |
|
704 | + |
|
705 | + /** |
|
706 | + * Wrapper for the native WP current_user_can() method. |
|
707 | + * This is provided as a handy method for a couple things: |
|
708 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
709 | + * write those filters wherever current_user_can is called). |
|
710 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
711 | + * |
|
712 | + * @since 4.5.0 |
|
713 | + * |
|
714 | + * @param string $cap The cap being checked. |
|
715 | + * @param string $context The context where the current_user_can is being called from. |
|
716 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
717 | + * filters. |
|
718 | + * |
|
719 | + * @return bool Whether user can or not. |
|
720 | + */ |
|
721 | + public function current_user_can($cap, $context, $id = 0) |
|
722 | + { |
|
723 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
724 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
725 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
726 | + $id); |
|
727 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
733 | + * |
|
734 | + * @param int|WP_User $user Either the user_id or a WP_User object |
|
735 | + * @param string $cap The capability string being checked |
|
736 | + * @param string $context The context where the user_can is being called from (used in filters). |
|
737 | + * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
738 | + * filters) |
|
739 | + * |
|
740 | + * @return bool Whether user can or not. |
|
741 | + */ |
|
742 | + public function user_can($user, $cap, $context, $id = 0) |
|
743 | + { |
|
744 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
745 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
746 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
747 | + $id); |
|
748 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * Wrapper for the native WP current_user_can_for_blog() method. |
|
754 | + * This is provided as a handy method for a couple things: |
|
755 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
756 | + * write those filters wherever current_user_can is called). |
|
757 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
758 | + * |
|
759 | + * @since 4.5.0 |
|
760 | + * |
|
761 | + * @param int $blog_id The blog id that is being checked for. |
|
762 | + * @param string $cap The cap being checked. |
|
763 | + * @param string $context The context where the current_user_can is being called from. |
|
764 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
765 | + * filters. |
|
766 | + * |
|
767 | + * @return bool Whether user can or not. |
|
768 | + */ |
|
769 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
770 | + { |
|
771 | + $user_can = ! empty($id) |
|
772 | + ? current_user_can_for_blog($blog_id, $cap, $id) |
|
773 | + : current_user_can($blog_id, $cap); |
|
774 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
775 | + $user_can = apply_filters( |
|
776 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
777 | + $user_can, |
|
778 | + $blog_id, |
|
779 | + $cap, |
|
780 | + $id |
|
781 | + ); |
|
782 | + $user_can = apply_filters( |
|
783 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
784 | + $user_can, |
|
785 | + $context, |
|
786 | + $blog_id, |
|
787 | + $cap, |
|
788 | + $id |
|
789 | + ); |
|
790 | + return $user_can; |
|
791 | + } |
|
792 | + |
|
793 | + |
|
794 | + /** |
|
795 | + * This helper method just returns an array of registered EE capabilities. |
|
796 | + * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
797 | + * role. |
|
798 | + * |
|
799 | + * @since 4.5.0 |
|
800 | + * |
|
801 | + * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
802 | + * for the given role are returned. |
|
803 | + * |
|
804 | + * @return array |
|
805 | + */ |
|
806 | + public function get_ee_capabilities($role = 'administrator') |
|
807 | + { |
|
808 | + $capabilities = $this->_init_caps_map(); |
|
809 | + if (empty($role)) { |
|
810 | + return $capabilities; |
|
811 | + } |
|
812 | + return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
813 | + } |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -827,142 +827,142 @@ discard block |
||
827 | 827 | abstract class EE_Meta_Capability_Map |
828 | 828 | { |
829 | 829 | |
830 | - public $meta_cap; |
|
831 | - |
|
832 | - /** |
|
833 | - * @var EEM_Base |
|
834 | - */ |
|
835 | - protected $_model; |
|
836 | - |
|
837 | - protected $_model_name; |
|
838 | - |
|
839 | - public $published_cap = ''; |
|
840 | - |
|
841 | - public $others_cap = ''; |
|
842 | - |
|
843 | - public $private_cap = ''; |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * constructor. |
|
848 | - * Receives the setup arguments for the map. |
|
849 | - * |
|
850 | - * @since 4.5.0 |
|
851 | - * |
|
852 | - * @param string $meta_cap What meta capability is this mapping. |
|
853 | - * @param array $map_values array { |
|
854 | - * //array of values that MUST match a count of 4. It's okay to send an empty string for |
|
855 | - * capabilities that don't get mapped to. |
|
856 | - * |
|
857 | - * @type $map_values [0] string A string representing the model name. Required. String's |
|
858 | - * should always be used when Menu Maps are registered via the |
|
859 | - * plugin API as models are not allowed to be instantiated when |
|
860 | - * in maintenance mode 2 (migrations). |
|
861 | - * @type $map_values [1] string represents the capability used for published. Optional. |
|
862 | - * @type $map_values [2] string represents the capability used for "others". Optional. |
|
863 | - * @type $map_values [3] string represents the capability used for private. Optional. |
|
864 | - * } |
|
865 | - * @throws EE_Error |
|
866 | - */ |
|
867 | - public function __construct($meta_cap, $map_values) |
|
868 | - { |
|
869 | - $this->meta_cap = $meta_cap; |
|
870 | - //verify there are four args in the $map_values array; |
|
871 | - if (count($map_values) !== 4) { |
|
872 | - throw new EE_Error( |
|
873 | - sprintf( |
|
874 | - __( |
|
875 | - 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
876 | - 'event_espresso' |
|
877 | - ), |
|
878 | - '<br>' . print_r($map_values, true) |
|
879 | - ) |
|
880 | - ); |
|
881 | - } |
|
882 | - //set properties |
|
883 | - $this->_model = null; |
|
884 | - $this->_model_name = $map_values[0]; |
|
885 | - $this->published_cap = (string)$map_values[1]; |
|
886 | - $this->others_cap = (string)$map_values[2]; |
|
887 | - $this->private_cap = (string)$map_values[3]; |
|
888 | - } |
|
889 | - |
|
890 | - /** |
|
891 | - * Makes it so this object stops filtering caps |
|
892 | - */ |
|
893 | - public function remove_filters() |
|
894 | - { |
|
895 | - remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
901 | - * |
|
902 | - * @since 4.5.0 |
|
903 | - * @throws EE_Error |
|
904 | - * |
|
905 | - * @return void |
|
906 | - */ |
|
907 | - public function ensure_is_model() |
|
908 | - { |
|
909 | - //is it already instantiated? |
|
910 | - if ($this->_model instanceof EEM_Base) { |
|
911 | - return; |
|
912 | - } |
|
913 | - //ensure model name is string |
|
914 | - $this->_model_name = (string)$this->_model_name; |
|
915 | - //error proof if the name has EEM in it |
|
916 | - $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
917 | - $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
918 | - if (! $this->_model instanceof EEM_Base) { |
|
919 | - throw new EE_Error( |
|
920 | - sprintf( |
|
921 | - __( |
|
922 | - 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
923 | - 'event_espresso' |
|
924 | - ), |
|
925 | - get_class($this), |
|
926 | - $this->_model |
|
927 | - ) |
|
928 | - ); |
|
929 | - } |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - /** |
|
934 | - * |
|
935 | - * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
936 | - * @since 4.6.x |
|
937 | - * |
|
938 | - * @param $caps |
|
939 | - * @param $cap |
|
940 | - * @param $user_id |
|
941 | - * @param $args |
|
942 | - * |
|
943 | - * @return array |
|
944 | - */ |
|
945 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
946 | - { |
|
947 | - return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
948 | - } |
|
949 | - |
|
950 | - |
|
951 | - /** |
|
952 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
953 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
954 | - * |
|
955 | - * @since 4.5.0 |
|
956 | - * @see wp-includes/capabilities.php |
|
957 | - * |
|
958 | - * @param array $caps actual users capabilities |
|
959 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
960 | - * @param int $user_id The user id |
|
961 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
962 | - * |
|
963 | - * @return array actual users capabilities |
|
964 | - */ |
|
965 | - abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
830 | + public $meta_cap; |
|
831 | + |
|
832 | + /** |
|
833 | + * @var EEM_Base |
|
834 | + */ |
|
835 | + protected $_model; |
|
836 | + |
|
837 | + protected $_model_name; |
|
838 | + |
|
839 | + public $published_cap = ''; |
|
840 | + |
|
841 | + public $others_cap = ''; |
|
842 | + |
|
843 | + public $private_cap = ''; |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * constructor. |
|
848 | + * Receives the setup arguments for the map. |
|
849 | + * |
|
850 | + * @since 4.5.0 |
|
851 | + * |
|
852 | + * @param string $meta_cap What meta capability is this mapping. |
|
853 | + * @param array $map_values array { |
|
854 | + * //array of values that MUST match a count of 4. It's okay to send an empty string for |
|
855 | + * capabilities that don't get mapped to. |
|
856 | + * |
|
857 | + * @type $map_values [0] string A string representing the model name. Required. String's |
|
858 | + * should always be used when Menu Maps are registered via the |
|
859 | + * plugin API as models are not allowed to be instantiated when |
|
860 | + * in maintenance mode 2 (migrations). |
|
861 | + * @type $map_values [1] string represents the capability used for published. Optional. |
|
862 | + * @type $map_values [2] string represents the capability used for "others". Optional. |
|
863 | + * @type $map_values [3] string represents the capability used for private. Optional. |
|
864 | + * } |
|
865 | + * @throws EE_Error |
|
866 | + */ |
|
867 | + public function __construct($meta_cap, $map_values) |
|
868 | + { |
|
869 | + $this->meta_cap = $meta_cap; |
|
870 | + //verify there are four args in the $map_values array; |
|
871 | + if (count($map_values) !== 4) { |
|
872 | + throw new EE_Error( |
|
873 | + sprintf( |
|
874 | + __( |
|
875 | + 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
876 | + 'event_espresso' |
|
877 | + ), |
|
878 | + '<br>' . print_r($map_values, true) |
|
879 | + ) |
|
880 | + ); |
|
881 | + } |
|
882 | + //set properties |
|
883 | + $this->_model = null; |
|
884 | + $this->_model_name = $map_values[0]; |
|
885 | + $this->published_cap = (string)$map_values[1]; |
|
886 | + $this->others_cap = (string)$map_values[2]; |
|
887 | + $this->private_cap = (string)$map_values[3]; |
|
888 | + } |
|
889 | + |
|
890 | + /** |
|
891 | + * Makes it so this object stops filtering caps |
|
892 | + */ |
|
893 | + public function remove_filters() |
|
894 | + { |
|
895 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
901 | + * |
|
902 | + * @since 4.5.0 |
|
903 | + * @throws EE_Error |
|
904 | + * |
|
905 | + * @return void |
|
906 | + */ |
|
907 | + public function ensure_is_model() |
|
908 | + { |
|
909 | + //is it already instantiated? |
|
910 | + if ($this->_model instanceof EEM_Base) { |
|
911 | + return; |
|
912 | + } |
|
913 | + //ensure model name is string |
|
914 | + $this->_model_name = (string)$this->_model_name; |
|
915 | + //error proof if the name has EEM in it |
|
916 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
917 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
918 | + if (! $this->_model instanceof EEM_Base) { |
|
919 | + throw new EE_Error( |
|
920 | + sprintf( |
|
921 | + __( |
|
922 | + 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
923 | + 'event_espresso' |
|
924 | + ), |
|
925 | + get_class($this), |
|
926 | + $this->_model |
|
927 | + ) |
|
928 | + ); |
|
929 | + } |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + /** |
|
934 | + * |
|
935 | + * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
936 | + * @since 4.6.x |
|
937 | + * |
|
938 | + * @param $caps |
|
939 | + * @param $cap |
|
940 | + * @param $user_id |
|
941 | + * @param $args |
|
942 | + * |
|
943 | + * @return array |
|
944 | + */ |
|
945 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
946 | + { |
|
947 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
948 | + } |
|
949 | + |
|
950 | + |
|
951 | + /** |
|
952 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
953 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
954 | + * |
|
955 | + * @since 4.5.0 |
|
956 | + * @see wp-includes/capabilities.php |
|
957 | + * |
|
958 | + * @param array $caps actual users capabilities |
|
959 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
960 | + * @param int $user_id The user id |
|
961 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
962 | + * |
|
963 | + * @return array actual users capabilities |
|
964 | + */ |
|
965 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | |
@@ -978,83 +978,83 @@ discard block |
||
978 | 978 | class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map |
979 | 979 | { |
980 | 980 | |
981 | - /** |
|
982 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
983 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
984 | - * |
|
985 | - * @since 4.5.0 |
|
986 | - * @see wp-includes/capabilities.php |
|
987 | - * |
|
988 | - * @param array $caps actual users capabilities |
|
989 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
990 | - * @param int $user_id The user id |
|
991 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
992 | - * |
|
993 | - * @return array actual users capabilities |
|
994 | - */ |
|
995 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | - { |
|
997 | - //only process if we're checking our mapped_cap |
|
998 | - if ($cap !== $this->meta_cap) { |
|
999 | - return $caps; |
|
1000 | - } |
|
1001 | - |
|
1002 | - //cast $user_id to int for later explicit comparisons |
|
1003 | - $user_id = (int) $user_id; |
|
1004 | - |
|
1005 | - /** @var EE_Base_Class $obj */ |
|
1006 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | - //if no obj then let's just do cap |
|
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1009 | - $caps[] = $cap; |
|
1010 | - return $caps; |
|
1011 | - } |
|
1012 | - if ($obj instanceof EE_CPT_Base) { |
|
1013 | - //if the item author is set and the user is the author... |
|
1014 | - if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | - if (empty($this->published_cap)) { |
|
1016 | - $caps[] = $cap; |
|
1017 | - } else { |
|
1018 | - //if obj is published... |
|
1019 | - if ($obj->status() === 'publish') { |
|
1020 | - $caps[] = $this->published_cap; |
|
1021 | - } else { |
|
1022 | - $caps[] = $cap; |
|
1023 | - } |
|
1024 | - } |
|
1025 | - } else { |
|
1026 | - //the user is trying to edit someone else's obj |
|
1027 | - if (! empty($this->others_cap)) { |
|
1028 | - $caps[] = $this->others_cap; |
|
1029 | - } |
|
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | - $caps[] = $this->published_cap; |
|
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | - $caps[] = $this->private_cap; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } else { |
|
1037 | - //not a cpt object so handled differently |
|
1038 | - $has_cap = false; |
|
1039 | - try { |
|
1040 | - $has_cap = method_exists($obj, 'wp_user') |
|
1041 | - && $obj->wp_user() |
|
1042 | - && $obj->wp_user() === $user_id; |
|
1043 | - } catch (Exception $e) { |
|
1044 | - if (WP_DEBUG) { |
|
1045 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | - } |
|
1047 | - } |
|
1048 | - if ($has_cap) { |
|
1049 | - $caps[] = $cap; |
|
1050 | - } else { |
|
1051 | - if (! empty($this->others_cap)) { |
|
1052 | - $caps[] = $this->others_cap; |
|
1053 | - } |
|
1054 | - } |
|
1055 | - } |
|
1056 | - return $caps; |
|
1057 | - } |
|
981 | + /** |
|
982 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
983 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
984 | + * |
|
985 | + * @since 4.5.0 |
|
986 | + * @see wp-includes/capabilities.php |
|
987 | + * |
|
988 | + * @param array $caps actual users capabilities |
|
989 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
990 | + * @param int $user_id The user id |
|
991 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
992 | + * |
|
993 | + * @return array actual users capabilities |
|
994 | + */ |
|
995 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | + { |
|
997 | + //only process if we're checking our mapped_cap |
|
998 | + if ($cap !== $this->meta_cap) { |
|
999 | + return $caps; |
|
1000 | + } |
|
1001 | + |
|
1002 | + //cast $user_id to int for later explicit comparisons |
|
1003 | + $user_id = (int) $user_id; |
|
1004 | + |
|
1005 | + /** @var EE_Base_Class $obj */ |
|
1006 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | + //if no obj then let's just do cap |
|
1008 | + if (! $obj instanceof EE_Base_Class) { |
|
1009 | + $caps[] = $cap; |
|
1010 | + return $caps; |
|
1011 | + } |
|
1012 | + if ($obj instanceof EE_CPT_Base) { |
|
1013 | + //if the item author is set and the user is the author... |
|
1014 | + if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | + if (empty($this->published_cap)) { |
|
1016 | + $caps[] = $cap; |
|
1017 | + } else { |
|
1018 | + //if obj is published... |
|
1019 | + if ($obj->status() === 'publish') { |
|
1020 | + $caps[] = $this->published_cap; |
|
1021 | + } else { |
|
1022 | + $caps[] = $cap; |
|
1023 | + } |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + //the user is trying to edit someone else's obj |
|
1027 | + if (! empty($this->others_cap)) { |
|
1028 | + $caps[] = $this->others_cap; |
|
1029 | + } |
|
1030 | + if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | + $caps[] = $this->published_cap; |
|
1032 | + } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | + $caps[] = $this->private_cap; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } else { |
|
1037 | + //not a cpt object so handled differently |
|
1038 | + $has_cap = false; |
|
1039 | + try { |
|
1040 | + $has_cap = method_exists($obj, 'wp_user') |
|
1041 | + && $obj->wp_user() |
|
1042 | + && $obj->wp_user() === $user_id; |
|
1043 | + } catch (Exception $e) { |
|
1044 | + if (WP_DEBUG) { |
|
1045 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | + } |
|
1047 | + } |
|
1048 | + if ($has_cap) { |
|
1049 | + $caps[] = $cap; |
|
1050 | + } else { |
|
1051 | + if (! empty($this->others_cap)) { |
|
1052 | + $caps[] = $this->others_cap; |
|
1053 | + } |
|
1054 | + } |
|
1055 | + } |
|
1056 | + return $caps; |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | |
@@ -1071,24 +1071,24 @@ discard block |
||
1071 | 1071 | class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit |
1072 | 1072 | { |
1073 | 1073 | |
1074 | - /** |
|
1075 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | - * |
|
1078 | - * @since 4.5.0 |
|
1079 | - * @see wp-includes/capabilities.php |
|
1080 | - * |
|
1081 | - * @param array $caps actual users capabilities |
|
1082 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1083 | - * @param int $user_id The user id |
|
1084 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1085 | - * |
|
1086 | - * @return array actual users capabilities |
|
1087 | - */ |
|
1088 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1089 | - { |
|
1090 | - return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1091 | - } |
|
1074 | + /** |
|
1075 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | + * |
|
1078 | + * @since 4.5.0 |
|
1079 | + * @see wp-includes/capabilities.php |
|
1080 | + * |
|
1081 | + * @param array $caps actual users capabilities |
|
1082 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1083 | + * @param int $user_id The user id |
|
1084 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1085 | + * |
|
1086 | + * @return array actual users capabilities |
|
1087 | + */ |
|
1088 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1089 | + { |
|
1090 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1091 | + } |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | |
@@ -1104,75 +1104,75 @@ discard block |
||
1104 | 1104 | class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map |
1105 | 1105 | { |
1106 | 1106 | |
1107 | - /** |
|
1108 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1109 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1110 | - * |
|
1111 | - * @since 4.5.0 |
|
1112 | - * @see wp-includes/capabilities.php |
|
1113 | - * |
|
1114 | - * @param array $caps actual users capabilities |
|
1115 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1116 | - * @param int $user_id The user id |
|
1117 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1118 | - * |
|
1119 | - * @return array actual users capabilities |
|
1120 | - */ |
|
1121 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1122 | - { |
|
1123 | - //only process if we're checking our mapped cap; |
|
1124 | - if ($cap !== $this->meta_cap) { |
|
1125 | - return $caps; |
|
1126 | - } |
|
1127 | - |
|
1128 | - //cast $user_id to int for later explicit comparisons |
|
1129 | - $user_id = (int) $user_id; |
|
1130 | - |
|
1131 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1132 | - //if no obj then let's just do cap |
|
1133 | - if (! $obj instanceof EE_Base_Class) { |
|
1134 | - $caps[] = $cap; |
|
1135 | - return $caps; |
|
1136 | - } |
|
1137 | - if ($obj instanceof EE_CPT_Base) { |
|
1138 | - $status_obj = get_post_status_object($obj->status()); |
|
1139 | - if ($status_obj->public) { |
|
1140 | - $caps[] = $cap; |
|
1141 | - return $caps; |
|
1142 | - } |
|
1143 | - //if the item author is set and the user is the author... |
|
1144 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1145 | - $caps[] = $cap; |
|
1146 | - } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1147 | - //the user is trying to view someone else's obj |
|
1148 | - $caps[] = $this->private_cap; |
|
1149 | - } elseif (! empty($this->others_cap)) { |
|
1150 | - $caps[] = $this->others_cap; |
|
1151 | - } else { |
|
1152 | - $caps[] = $cap; |
|
1153 | - } |
|
1154 | - } else { |
|
1155 | - //not a cpt object so handled differently |
|
1156 | - $has_cap = false; |
|
1157 | - try { |
|
1158 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1159 | - } catch (Exception $e) { |
|
1160 | - if (WP_DEBUG) { |
|
1161 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1162 | - } |
|
1163 | - } |
|
1164 | - if ($has_cap) { |
|
1165 | - $caps[] = $cap; |
|
1166 | - } elseif (! empty($this->private_cap)) { |
|
1167 | - $caps[] = $this->private_cap; |
|
1168 | - } elseif (! empty($this->others_cap)) { |
|
1169 | - $caps[] = $this->others_cap; |
|
1170 | - } else { |
|
1171 | - $caps[] = $cap; |
|
1172 | - } |
|
1173 | - } |
|
1174 | - return $caps; |
|
1175 | - } |
|
1107 | + /** |
|
1108 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1109 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1110 | + * |
|
1111 | + * @since 4.5.0 |
|
1112 | + * @see wp-includes/capabilities.php |
|
1113 | + * |
|
1114 | + * @param array $caps actual users capabilities |
|
1115 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1116 | + * @param int $user_id The user id |
|
1117 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1118 | + * |
|
1119 | + * @return array actual users capabilities |
|
1120 | + */ |
|
1121 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1122 | + { |
|
1123 | + //only process if we're checking our mapped cap; |
|
1124 | + if ($cap !== $this->meta_cap) { |
|
1125 | + return $caps; |
|
1126 | + } |
|
1127 | + |
|
1128 | + //cast $user_id to int for later explicit comparisons |
|
1129 | + $user_id = (int) $user_id; |
|
1130 | + |
|
1131 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1132 | + //if no obj then let's just do cap |
|
1133 | + if (! $obj instanceof EE_Base_Class) { |
|
1134 | + $caps[] = $cap; |
|
1135 | + return $caps; |
|
1136 | + } |
|
1137 | + if ($obj instanceof EE_CPT_Base) { |
|
1138 | + $status_obj = get_post_status_object($obj->status()); |
|
1139 | + if ($status_obj->public) { |
|
1140 | + $caps[] = $cap; |
|
1141 | + return $caps; |
|
1142 | + } |
|
1143 | + //if the item author is set and the user is the author... |
|
1144 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1145 | + $caps[] = $cap; |
|
1146 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1147 | + //the user is trying to view someone else's obj |
|
1148 | + $caps[] = $this->private_cap; |
|
1149 | + } elseif (! empty($this->others_cap)) { |
|
1150 | + $caps[] = $this->others_cap; |
|
1151 | + } else { |
|
1152 | + $caps[] = $cap; |
|
1153 | + } |
|
1154 | + } else { |
|
1155 | + //not a cpt object so handled differently |
|
1156 | + $has_cap = false; |
|
1157 | + try { |
|
1158 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1159 | + } catch (Exception $e) { |
|
1160 | + if (WP_DEBUG) { |
|
1161 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1162 | + } |
|
1163 | + } |
|
1164 | + if ($has_cap) { |
|
1165 | + $caps[] = $cap; |
|
1166 | + } elseif (! empty($this->private_cap)) { |
|
1167 | + $caps[] = $this->private_cap; |
|
1168 | + } elseif (! empty($this->others_cap)) { |
|
1169 | + $caps[] = $this->others_cap; |
|
1170 | + } else { |
|
1171 | + $caps[] = $cap; |
|
1172 | + } |
|
1173 | + } |
|
1174 | + return $caps; |
|
1175 | + } |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
@@ -1189,52 +1189,52 @@ discard block |
||
1189 | 1189 | class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map |
1190 | 1190 | { |
1191 | 1191 | |
1192 | - /** |
|
1193 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1194 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1195 | - * |
|
1196 | - * @since 4.5.0 |
|
1197 | - * @see wp-includes/capabilities.php |
|
1198 | - * |
|
1199 | - * @param array $caps actual users capabilities |
|
1200 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1201 | - * @param int $user_id The user id |
|
1202 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1203 | - * |
|
1204 | - * @return array actual users capabilities |
|
1205 | - */ |
|
1206 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1207 | - { |
|
1208 | - //only process if we're checking our mapped_cap |
|
1209 | - if ($cap !== $this->meta_cap) { |
|
1210 | - return $caps; |
|
1211 | - } |
|
1212 | - |
|
1213 | - //cast $user_id to int for later explicit comparisons |
|
1214 | - $user_id = (int) $user_id; |
|
1215 | - |
|
1216 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1217 | - //if no obj then let's just do cap |
|
1218 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1219 | - $caps[] = $cap; |
|
1220 | - return $caps; |
|
1221 | - } |
|
1222 | - $is_global = $obj->is_global(); |
|
1223 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1224 | - if ($is_global) { |
|
1225 | - $caps[] = $this->private_cap; |
|
1226 | - } else { |
|
1227 | - $caps[] = $cap; |
|
1228 | - } |
|
1229 | - } else { |
|
1230 | - if ($is_global) { |
|
1231 | - $caps[] = $this->private_cap; |
|
1232 | - } else { |
|
1233 | - $caps[] = $this->others_cap; |
|
1234 | - } |
|
1235 | - } |
|
1236 | - return $caps; |
|
1237 | - } |
|
1192 | + /** |
|
1193 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1194 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1195 | + * |
|
1196 | + * @since 4.5.0 |
|
1197 | + * @see wp-includes/capabilities.php |
|
1198 | + * |
|
1199 | + * @param array $caps actual users capabilities |
|
1200 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1201 | + * @param int $user_id The user id |
|
1202 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1203 | + * |
|
1204 | + * @return array actual users capabilities |
|
1205 | + */ |
|
1206 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1207 | + { |
|
1208 | + //only process if we're checking our mapped_cap |
|
1209 | + if ($cap !== $this->meta_cap) { |
|
1210 | + return $caps; |
|
1211 | + } |
|
1212 | + |
|
1213 | + //cast $user_id to int for later explicit comparisons |
|
1214 | + $user_id = (int) $user_id; |
|
1215 | + |
|
1216 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1217 | + //if no obj then let's just do cap |
|
1218 | + if (! $obj instanceof EE_Message_Template_Group) { |
|
1219 | + $caps[] = $cap; |
|
1220 | + return $caps; |
|
1221 | + } |
|
1222 | + $is_global = $obj->is_global(); |
|
1223 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1224 | + if ($is_global) { |
|
1225 | + $caps[] = $this->private_cap; |
|
1226 | + } else { |
|
1227 | + $caps[] = $cap; |
|
1228 | + } |
|
1229 | + } else { |
|
1230 | + if ($is_global) { |
|
1231 | + $caps[] = $this->private_cap; |
|
1232 | + } else { |
|
1233 | + $caps[] = $this->others_cap; |
|
1234 | + } |
|
1235 | + } |
|
1236 | + return $caps; |
|
1237 | + } |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1251,41 +1251,41 @@ discard block |
||
1251 | 1251 | class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map |
1252 | 1252 | { |
1253 | 1253 | |
1254 | - /** |
|
1255 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1256 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1257 | - * |
|
1258 | - * @since 4.5.0 |
|
1259 | - * @see wp-includes/capabilities.php |
|
1260 | - * |
|
1261 | - * @param array $caps actual users capabilities |
|
1262 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1263 | - * @param int $user_id The user id |
|
1264 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1265 | - * |
|
1266 | - * @return array actual users capabilities |
|
1267 | - */ |
|
1268 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1269 | - { |
|
1270 | - //only process if we're checking our mapped_cap |
|
1271 | - if ($cap !== $this->meta_cap) { |
|
1272 | - return $caps; |
|
1273 | - } |
|
1274 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1275 | - //if no obj then let's just do cap |
|
1276 | - if (! $obj instanceof EE_Base_Class) { |
|
1277 | - $caps[] = $cap; |
|
1278 | - return $caps; |
|
1279 | - } |
|
1280 | - $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1281 | - $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1282 | - if ($is_system) { |
|
1283 | - $caps[] = $this->private_cap; |
|
1284 | - } else { |
|
1285 | - $caps[] = $cap; |
|
1286 | - } |
|
1287 | - return $caps; |
|
1288 | - } |
|
1254 | + /** |
|
1255 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1256 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1257 | + * |
|
1258 | + * @since 4.5.0 |
|
1259 | + * @see wp-includes/capabilities.php |
|
1260 | + * |
|
1261 | + * @param array $caps actual users capabilities |
|
1262 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1263 | + * @param int $user_id The user id |
|
1264 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1265 | + * |
|
1266 | + * @return array actual users capabilities |
|
1267 | + */ |
|
1268 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1269 | + { |
|
1270 | + //only process if we're checking our mapped_cap |
|
1271 | + if ($cap !== $this->meta_cap) { |
|
1272 | + return $caps; |
|
1273 | + } |
|
1274 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1275 | + //if no obj then let's just do cap |
|
1276 | + if (! $obj instanceof EE_Base_Class) { |
|
1277 | + $caps[] = $cap; |
|
1278 | + return $caps; |
|
1279 | + } |
|
1280 | + $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1281 | + $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1282 | + if ($is_system) { |
|
1283 | + $caps[] = $this->private_cap; |
|
1284 | + } else { |
|
1285 | + $caps[] = $cap; |
|
1286 | + } |
|
1287 | + return $caps; |
|
1288 | + } |
|
1289 | 1289 | |
1290 | 1290 | |
1291 | 1291 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public static function instance() |
61 | 61 | { |
62 | 62 | //check if instantiated, and if not do so. |
63 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
63 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
113 | 113 | $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
114 | 114 | //add filter for map_meta_caps but only if models can query. |
115 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
115 | + if ( ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | 116 | add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
117 | 117 | } |
118 | 118 | } |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
271 | 271 | //loop through our _meta_caps array |
272 | 272 | foreach ($this->_meta_caps as $meta_map) { |
273 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
273 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | 274 | continue; |
275 | 275 | } |
276 | 276 | // don't load models if there is no object ID in the args |
277 | - if(!empty($args[0])){ |
|
277 | + if ( ! empty($args[0])) { |
|
278 | 278 | $meta_map->ensure_is_model(); |
279 | 279 | } |
280 | 280 | $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | foreach ($caps_map as $role => $caps_for_role) { |
633 | 633 | foreach ($caps_for_role as $cap) { |
634 | 634 | //first check we haven't already added this cap before, or it's a reset |
635 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
635 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
636 | 636 | if ($this->add_cap_to_role($role, $cap)) { |
637 | - $caps_set_before[ $role ][] = $cap; |
|
637 | + $caps_set_before[$role][] = $cap; |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $role_object = get_role($role); |
666 | 666 | //if the role isn't available then we create it. |
667 | - if (! $role_object instanceof WP_Role) { |
|
667 | + if ( ! $role_object instanceof WP_Role) { |
|
668 | 668 | //if a plugin wants to create a specific role name then they should create the role before |
669 | 669 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
670 | 670 | // - removes any `ee_` namespacing from the start of the slug. |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function current_user_can($cap, $context, $id = 0) |
722 | 722 | { |
723 | 723 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
724 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
724 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
725 | 725 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
726 | 726 | $id); |
727 | 727 | return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | public function user_can($user, $cap, $context, $id = 0) |
743 | 743 | { |
744 | 744 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
745 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
745 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
746 | 746 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
747 | 747 | $id); |
748 | 748 | return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | : current_user_can($blog_id, $cap); |
774 | 774 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
775 | 775 | $user_can = apply_filters( |
776 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
776 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, |
|
777 | 777 | $user_can, |
778 | 778 | $blog_id, |
779 | 779 | $cap, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | if (empty($role)) { |
810 | 810 | return $capabilities; |
811 | 811 | } |
812 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
812 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
876 | 876 | 'event_espresso' |
877 | 877 | ), |
878 | - '<br>' . print_r($map_values, true) |
|
878 | + '<br>'.print_r($map_values, true) |
|
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | } |
882 | 882 | //set properties |
883 | 883 | $this->_model = null; |
884 | 884 | $this->_model_name = $map_values[0]; |
885 | - $this->published_cap = (string)$map_values[1]; |
|
886 | - $this->others_cap = (string)$map_values[2]; |
|
887 | - $this->private_cap = (string)$map_values[3]; |
|
885 | + $this->published_cap = (string) $map_values[1]; |
|
886 | + $this->others_cap = (string) $map_values[2]; |
|
887 | + $this->private_cap = (string) $map_values[3]; |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -911,11 +911,11 @@ discard block |
||
911 | 911 | return; |
912 | 912 | } |
913 | 913 | //ensure model name is string |
914 | - $this->_model_name = (string)$this->_model_name; |
|
914 | + $this->_model_name = (string) $this->_model_name; |
|
915 | 915 | //error proof if the name has EEM in it |
916 | 916 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
917 | 917 | $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
918 | - if (! $this->_model instanceof EEM_Base) { |
|
918 | + if ( ! $this->_model instanceof EEM_Base) { |
|
919 | 919 | throw new EE_Error( |
920 | 920 | sprintf( |
921 | 921 | __( |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | /** @var EE_Base_Class $obj */ |
1006 | 1006 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1007 | 1007 | //if no obj then let's just do cap |
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1008 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1009 | 1009 | $caps[] = $cap; |
1010 | 1010 | return $caps; |
1011 | 1011 | } |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } else { |
1026 | 1026 | //the user is trying to edit someone else's obj |
1027 | - if (! empty($this->others_cap)) { |
|
1027 | + if ( ! empty($this->others_cap)) { |
|
1028 | 1028 | $caps[] = $this->others_cap; |
1029 | 1029 | } |
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1030 | + if ( ! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | 1031 | $caps[] = $this->published_cap; |
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1032 | + } elseif ( ! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | 1033 | $caps[] = $this->private_cap; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | if ($has_cap) { |
1049 | 1049 | $caps[] = $cap; |
1050 | 1050 | } else { |
1051 | - if (! empty($this->others_cap)) { |
|
1051 | + if ( ! empty($this->others_cap)) { |
|
1052 | 1052 | $caps[] = $this->others_cap; |
1053 | 1053 | } |
1054 | 1054 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1132 | 1132 | //if no obj then let's just do cap |
1133 | - if (! $obj instanceof EE_Base_Class) { |
|
1133 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1134 | 1134 | $caps[] = $cap; |
1135 | 1135 | return $caps; |
1136 | 1136 | } |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | } elseif ($status_obj->private && ! empty($this->private_cap)) { |
1147 | 1147 | //the user is trying to view someone else's obj |
1148 | 1148 | $caps[] = $this->private_cap; |
1149 | - } elseif (! empty($this->others_cap)) { |
|
1149 | + } elseif ( ! empty($this->others_cap)) { |
|
1150 | 1150 | $caps[] = $this->others_cap; |
1151 | 1151 | } else { |
1152 | 1152 | $caps[] = $cap; |
@@ -1163,9 +1163,9 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | if ($has_cap) { |
1165 | 1165 | $caps[] = $cap; |
1166 | - } elseif (! empty($this->private_cap)) { |
|
1166 | + } elseif ( ! empty($this->private_cap)) { |
|
1167 | 1167 | $caps[] = $this->private_cap; |
1168 | - } elseif (! empty($this->others_cap)) { |
|
1168 | + } elseif ( ! empty($this->others_cap)) { |
|
1169 | 1169 | $caps[] = $this->others_cap; |
1170 | 1170 | } else { |
1171 | 1171 | $caps[] = $cap; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1217 | 1217 | //if no obj then let's just do cap |
1218 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1218 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1219 | 1219 | $caps[] = $cap; |
1220 | 1220 | return $caps; |
1221 | 1221 | } |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | } |
1274 | 1274 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1275 | 1275 | //if no obj then let's just do cap |
1276 | - if (! $obj instanceof EE_Base_Class) { |
|
1276 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1277 | 1277 | $caps[] = $cap; |
1278 | 1278 | return $caps; |
1279 | 1279 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use ReflectionException; |
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 | |
@@ -25,53 +25,53 @@ discard block |
||
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @param Exception $exception |
|
30 | - * @throws Exception |
|
31 | - */ |
|
32 | - public function __construct(Exception $exception) |
|
33 | - { |
|
34 | - if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
35 | - $this->displayException($exception); |
|
36 | - } else { |
|
37 | - throw $exception; |
|
38 | - } |
|
39 | - } |
|
28 | + /** |
|
29 | + * @param Exception $exception |
|
30 | + * @throws Exception |
|
31 | + */ |
|
32 | + public function __construct(Exception $exception) |
|
33 | + { |
|
34 | + if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
35 | + $this->displayException($exception); |
|
36 | + } else { |
|
37 | + throw $exception; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @access protected |
|
45 | - * @param Exception $exception |
|
46 | - * @throws ReflectionException |
|
47 | - */ |
|
48 | - protected function displayException(Exception $exception) |
|
49 | - { |
|
50 | - $error_code = ''; |
|
51 | - $trace_details = ''; |
|
52 | - $time = time(); |
|
53 | - $trace = $exception->getTrace(); |
|
54 | - // get separate user and developer messages if they exist |
|
55 | - $msg = explode('||', $exception->getMessage()); |
|
56 | - $user_msg = $msg[0]; |
|
57 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
58 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
59 | - // start gathering output |
|
60 | - $output = $this->exceptionStyles(); |
|
61 | - $output .= ' |
|
43 | + /** |
|
44 | + * @access protected |
|
45 | + * @param Exception $exception |
|
46 | + * @throws ReflectionException |
|
47 | + */ |
|
48 | + protected function displayException(Exception $exception) |
|
49 | + { |
|
50 | + $error_code = ''; |
|
51 | + $trace_details = ''; |
|
52 | + $time = time(); |
|
53 | + $trace = $exception->getTrace(); |
|
54 | + // get separate user and developer messages if they exist |
|
55 | + $msg = explode('||', $exception->getMessage()); |
|
56 | + $user_msg = $msg[0]; |
|
57 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
58 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
59 | + // start gathering output |
|
60 | + $output = $this->exceptionStyles(); |
|
61 | + $output .= ' |
|
62 | 62 | <div id="ee-error-message" class="error">'; |
63 | - if (! WP_DEBUG) { |
|
64 | - $output .= ' |
|
63 | + if (! WP_DEBUG) { |
|
64 | + $output .= ' |
|
65 | 65 | <p>'; |
66 | - } |
|
67 | - // process trace info |
|
68 | - if (empty($trace)) { |
|
69 | - $trace_details .= __( |
|
70 | - 'Sorry, but no trace information was available for this exception.', |
|
71 | - 'event_espresso' |
|
72 | - ); |
|
73 | - } else { |
|
74 | - $trace_details .= ' |
|
66 | + } |
|
67 | + // process trace info |
|
68 | + if (empty($trace)) { |
|
69 | + $trace_details .= __( |
|
70 | + 'Sorry, but no trace information was available for this exception.', |
|
71 | + 'event_espresso' |
|
72 | + ); |
|
73 | + } else { |
|
74 | + $trace_details .= ' |
|
75 | 75 | <div id="ee-trace-details"> |
76 | 76 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
77 | 77 | <tr> |
@@ -79,255 +79,255 @@ discard block |
||
79 | 79 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
80 | 80 | <th scope="col" align="left" style="width:40%;">File</th> |
81 | 81 | <th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __('Method( arguments )', |
82 | - 'event_espresso') . '</th> |
|
82 | + 'event_espresso') . '</th> |
|
83 | 83 | </tr>'; |
84 | - $last_on_stack = count($trace) - 1; |
|
85 | - // reverse array so that stack is in proper chronological order |
|
86 | - $sorted_trace = array_reverse($trace); |
|
87 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
88 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
89 | - $class = isset($trace['class']) ? $trace['class'] : ''; |
|
90 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
91 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
92 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
93 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
94 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
95 | - $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
|
96 | - if (empty($file) && ! empty($class)) { |
|
97 | - $a = new ReflectionClass($class); |
|
98 | - $file = $a->getFileName(); |
|
99 | - if (empty($line) && ! empty($function)) { |
|
100 | - $b = new \ReflectionMethod($class, $function); |
|
101 | - $line = $b->getStartLine(); |
|
102 | - } |
|
103 | - } |
|
104 | - if ($nmbr === $last_on_stack) { |
|
105 | - $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
|
106 | - $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
|
107 | - $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
108 | - } |
|
109 | - $file = \EEH_File::standardise_directory_separators($file); |
|
110 | - $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
111 | - $line = ! empty($line) ? $line : ' '; |
|
112 | - $file = ! empty($file) ? $file : ' '; |
|
113 | - $class_display = ! empty($class) ? $class : ''; |
|
114 | - $type = ! empty($type) ? $type : ''; |
|
115 | - $function = ! empty($function) ? $function : ''; |
|
116 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
117 | - $trace_details .= ' |
|
84 | + $last_on_stack = count($trace) - 1; |
|
85 | + // reverse array so that stack is in proper chronological order |
|
86 | + $sorted_trace = array_reverse($trace); |
|
87 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
88 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
89 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
90 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
91 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
92 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
93 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
94 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
95 | + $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
|
96 | + if (empty($file) && ! empty($class)) { |
|
97 | + $a = new ReflectionClass($class); |
|
98 | + $file = $a->getFileName(); |
|
99 | + if (empty($line) && ! empty($function)) { |
|
100 | + $b = new \ReflectionMethod($class, $function); |
|
101 | + $line = $b->getStartLine(); |
|
102 | + } |
|
103 | + } |
|
104 | + if ($nmbr === $last_on_stack) { |
|
105 | + $file = $exception->getFile() !== '' ? $exception->getFile() : $file; |
|
106 | + $line = $exception->getLine() !== '' ? $exception->getLine() : $line; |
|
107 | + $error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
108 | + } |
|
109 | + $file = \EEH_File::standardise_directory_separators($file); |
|
110 | + $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
111 | + $line = ! empty($line) ? $line : ' '; |
|
112 | + $file = ! empty($file) ? $file : ' '; |
|
113 | + $class_display = ! empty($class) ? $class : ''; |
|
114 | + $type = ! empty($type) ? $type : ''; |
|
115 | + $function = ! empty($function) ? $function : ''; |
|
116 | + $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
117 | + $trace_details .= ' |
|
118 | 118 | <tr> |
119 | 119 | <td align="right" valign="top" class="' |
120 | - . $zebra |
|
121 | - . '">' |
|
122 | - . $nmbr |
|
123 | - . '</td> |
|
120 | + . $zebra |
|
121 | + . '">' |
|
122 | + . $nmbr |
|
123 | + . '</td> |
|
124 | 124 | <td align="right" valign="top" class="' |
125 | - . $zebra |
|
126 | - . '">' |
|
127 | - . $line |
|
128 | - . '</td> |
|
125 | + . $zebra |
|
126 | + . '">' |
|
127 | + . $line |
|
128 | + . '</td> |
|
129 | 129 | <td align="left" valign="top" class="' |
130 | - . $zebra |
|
131 | - . '">' |
|
132 | - . $file |
|
133 | - . '</td> |
|
130 | + . $zebra |
|
131 | + . '">' |
|
132 | + . $file |
|
133 | + . '</td> |
|
134 | 134 | <td align="left" valign="top" class="' |
135 | - . $zebra |
|
136 | - . '">' |
|
137 | - . $class_display |
|
138 | - . $type |
|
139 | - . $function |
|
140 | - . $args |
|
141 | - . '</td> |
|
135 | + . $zebra |
|
136 | + . '">' |
|
137 | + . $class_display |
|
138 | + . $type |
|
139 | + . $function |
|
140 | + . $args |
|
141 | + . '</td> |
|
142 | 142 | </tr>'; |
143 | - } |
|
144 | - $trace_details .= ' |
|
143 | + } |
|
144 | + $trace_details .= ' |
|
145 | 145 | </table> |
146 | 146 | </div>'; |
147 | - } |
|
148 | - $code = $exception->getCode() ? $exception->getCode() : $error_code; |
|
149 | - // add generic non-identifying messages for non-privileged users |
|
150 | - if (! WP_DEBUG) { |
|
151 | - $output .= '<span class="ee-error-user-msg-spn">' |
|
152 | - . trim($msg) |
|
153 | - . '</span> <sup>' |
|
154 | - . $code |
|
155 | - . '</sup><br />'; |
|
156 | - } else { |
|
157 | - // or helpful developer messages if debugging is on |
|
158 | - $output .= ' |
|
147 | + } |
|
148 | + $code = $exception->getCode() ? $exception->getCode() : $error_code; |
|
149 | + // add generic non-identifying messages for non-privileged users |
|
150 | + if (! WP_DEBUG) { |
|
151 | + $output .= '<span class="ee-error-user-msg-spn">' |
|
152 | + . trim($msg) |
|
153 | + . '</span> <sup>' |
|
154 | + . $code |
|
155 | + . '</sup><br />'; |
|
156 | + } else { |
|
157 | + // or helpful developer messages if debugging is on |
|
158 | + $output .= ' |
|
159 | 159 | <div class="ee-error-dev-msg-dv"> |
160 | 160 | <p class="ee-error-dev-msg-pg"> |
161 | 161 | ' |
162 | - . sprintf( |
|
163 | - __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
164 | - '<strong class="ee-error-dev-msg-str">', |
|
165 | - get_class($exception), |
|
166 | - '</strong> <span>', |
|
167 | - $code . '</span>' |
|
168 | - ) |
|
169 | - . '<br /> |
|
162 | + . sprintf( |
|
163 | + __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
164 | + '<strong class="ee-error-dev-msg-str">', |
|
165 | + get_class($exception), |
|
166 | + '</strong> <span>', |
|
167 | + $code . '</span>' |
|
168 | + ) |
|
169 | + . '<br /> |
|
170 | 170 | <span class="big-text">"' |
171 | - . trim($msg) |
|
172 | - . '"</span><br/> |
|
171 | + . trim($msg) |
|
172 | + . '"</span><br/> |
|
173 | 173 | <a id="display-ee-error-trace-1' |
174 | - . $time |
|
175 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
176 | - . $time |
|
177 | - . '"> |
|
174 | + . $time |
|
175 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
176 | + . $time |
|
177 | + . '"> |
|
178 | 178 | ' |
179 | - . __('click to view backtrace and class/method details', 'event_espresso') |
|
180 | - . ' |
|
179 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
180 | + . ' |
|
181 | 181 | </a><br /> |
182 | 182 | ' |
183 | - . $exception->getFile() |
|
184 | - . sprintf( |
|
185 | - __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
186 | - ' <span class="small-text lt-grey-text">', |
|
187 | - $exception->getLine(), |
|
188 | - '</span>' |
|
189 | - ) |
|
190 | - . ' |
|
183 | + . $exception->getFile() |
|
184 | + . sprintf( |
|
185 | + __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
186 | + ' <span class="small-text lt-grey-text">', |
|
187 | + $exception->getLine(), |
|
188 | + '</span>' |
|
189 | + ) |
|
190 | + . ' |
|
191 | 191 | </p> |
192 | 192 | <div id="ee-error-trace-1' |
193 | - . $time |
|
194 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
193 | + . $time |
|
194 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
195 | 195 | ' |
196 | - . $trace_details; |
|
197 | - if (! empty($class)) { |
|
198 | - $output .= ' |
|
196 | + . $trace_details; |
|
197 | + if (! empty($class)) { |
|
198 | + $output .= ' |
|
199 | 199 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
200 | 200 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
201 | 201 | <h3>' . __('Class Details', 'event_espresso') . '</h3>'; |
202 | - $a = new ReflectionClass($class); |
|
203 | - $output .= ' |
|
202 | + $a = new ReflectionClass($class); |
|
203 | + $output .= ' |
|
204 | 204 | <pre>' . $a . '</pre> |
205 | 205 | </div> |
206 | 206 | </div>'; |
207 | - } |
|
208 | - $output .= ' |
|
207 | + } |
|
208 | + $output .= ' |
|
209 | 209 | </div> |
210 | 210 | </div> |
211 | 211 | <br />'; |
212 | - } |
|
213 | - // remove last linebreak |
|
214 | - $output = substr($output, 0, -6); |
|
215 | - if (! WP_DEBUG) { |
|
216 | - $output .= ' |
|
212 | + } |
|
213 | + // remove last linebreak |
|
214 | + $output = substr($output, 0, -6); |
|
215 | + if (! WP_DEBUG) { |
|
216 | + $output .= ' |
|
217 | 217 | </p>'; |
218 | - } |
|
219 | - $output .= ' |
|
218 | + } |
|
219 | + $output .= ' |
|
220 | 220 | </div>'; |
221 | - $output .= $this->printScripts(true); |
|
222 | - if (defined('DOING_AJAX')) { |
|
223 | - echo wp_json_encode(array('error' => $output)); |
|
224 | - exit(); |
|
225 | - } |
|
226 | - echo $output; |
|
227 | - } |
|
221 | + $output .= $this->printScripts(true); |
|
222 | + if (defined('DOING_AJAX')) { |
|
223 | + echo wp_json_encode(array('error' => $output)); |
|
224 | + exit(); |
|
225 | + } |
|
226 | + echo $output; |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | 230 | |
231 | - /** |
|
232 | - * generate string from exception trace args |
|
233 | - * |
|
234 | - * @param array $arguments |
|
235 | - * @param int $indent |
|
236 | - * @param bool $array |
|
237 | - * @return string |
|
238 | - */ |
|
239 | - private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
240 | - { |
|
241 | - $args = array(); |
|
242 | - $args_count = count($arguments); |
|
243 | - if ($args_count > 2) { |
|
244 | - $indent++; |
|
245 | - $args[] = '<br />'; |
|
246 | - } |
|
247 | - $x = 0; |
|
248 | - foreach ($arguments as $arg) { |
|
249 | - $x++; |
|
250 | - for ($i = 0; $i < $indent; $i++) { |
|
251 | - $args[] = ' '; |
|
252 | - } |
|
253 | - if (is_string($arg)) { |
|
254 | - if (! $array && strlen($arg) > 75) { |
|
255 | - $args[] = '<br />'; |
|
256 | - for ($i = 0; $i <= $indent; $i++) { |
|
257 | - $args[] = ' '; |
|
258 | - } |
|
259 | - $args[] = "'" . $arg . "'<br />"; |
|
260 | - } else { |
|
261 | - $args[] = " '" . $arg . "'"; |
|
262 | - } |
|
263 | - } elseif (is_array($arg)) { |
|
264 | - $arg_count = count($arg); |
|
265 | - if ($arg_count > 2) { |
|
266 | - $indent++; |
|
267 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
268 | - $indent--; |
|
269 | - } else if ($arg_count === 0) { |
|
270 | - $args[] = ' array()'; |
|
271 | - } else { |
|
272 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
273 | - } |
|
274 | - } elseif ($arg === null) { |
|
275 | - $args[] = ' null'; |
|
276 | - } elseif (is_bool($arg)) { |
|
277 | - $args[] = $arg ? ' true' : ' false'; |
|
278 | - } elseif (is_object($arg)) { |
|
279 | - $args[] = get_class($arg); |
|
280 | - } elseif (is_resource($arg)) { |
|
281 | - $args[] = get_resource_type($arg); |
|
282 | - } else { |
|
283 | - $args[] = $arg; |
|
284 | - } |
|
285 | - if ($x === $args_count) { |
|
286 | - if ($args_count > 2) { |
|
287 | - $args[] = '<br />'; |
|
288 | - $indent--; |
|
289 | - for ($i = 1; $i < $indent; $i++) { |
|
290 | - $args[] = ' '; |
|
291 | - } |
|
292 | - } |
|
293 | - } else { |
|
294 | - $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
295 | - } |
|
296 | - } |
|
297 | - return implode('', $args); |
|
298 | - } |
|
231 | + /** |
|
232 | + * generate string from exception trace args |
|
233 | + * |
|
234 | + * @param array $arguments |
|
235 | + * @param int $indent |
|
236 | + * @param bool $array |
|
237 | + * @return string |
|
238 | + */ |
|
239 | + private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
240 | + { |
|
241 | + $args = array(); |
|
242 | + $args_count = count($arguments); |
|
243 | + if ($args_count > 2) { |
|
244 | + $indent++; |
|
245 | + $args[] = '<br />'; |
|
246 | + } |
|
247 | + $x = 0; |
|
248 | + foreach ($arguments as $arg) { |
|
249 | + $x++; |
|
250 | + for ($i = 0; $i < $indent; $i++) { |
|
251 | + $args[] = ' '; |
|
252 | + } |
|
253 | + if (is_string($arg)) { |
|
254 | + if (! $array && strlen($arg) > 75) { |
|
255 | + $args[] = '<br />'; |
|
256 | + for ($i = 0; $i <= $indent; $i++) { |
|
257 | + $args[] = ' '; |
|
258 | + } |
|
259 | + $args[] = "'" . $arg . "'<br />"; |
|
260 | + } else { |
|
261 | + $args[] = " '" . $arg . "'"; |
|
262 | + } |
|
263 | + } elseif (is_array($arg)) { |
|
264 | + $arg_count = count($arg); |
|
265 | + if ($arg_count > 2) { |
|
266 | + $indent++; |
|
267 | + $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
268 | + $indent--; |
|
269 | + } else if ($arg_count === 0) { |
|
270 | + $args[] = ' array()'; |
|
271 | + } else { |
|
272 | + $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
273 | + } |
|
274 | + } elseif ($arg === null) { |
|
275 | + $args[] = ' null'; |
|
276 | + } elseif (is_bool($arg)) { |
|
277 | + $args[] = $arg ? ' true' : ' false'; |
|
278 | + } elseif (is_object($arg)) { |
|
279 | + $args[] = get_class($arg); |
|
280 | + } elseif (is_resource($arg)) { |
|
281 | + $args[] = get_resource_type($arg); |
|
282 | + } else { |
|
283 | + $args[] = $arg; |
|
284 | + } |
|
285 | + if ($x === $args_count) { |
|
286 | + if ($args_count > 2) { |
|
287 | + $args[] = '<br />'; |
|
288 | + $indent--; |
|
289 | + for ($i = 1; $i < $indent; $i++) { |
|
290 | + $args[] = ' '; |
|
291 | + } |
|
292 | + } |
|
293 | + } else { |
|
294 | + $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
295 | + } |
|
296 | + } |
|
297 | + return implode('', $args); |
|
298 | + } |
|
299 | 299 | |
300 | 300 | |
301 | 301 | |
302 | - /** |
|
303 | - * create error code from filepath, function name, |
|
304 | - * and line number where exception or error was thrown |
|
305 | - * |
|
306 | - * @access protected |
|
307 | - * @param string $file |
|
308 | - * @param string $func |
|
309 | - * @param string $line |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - protected function generate_error_code($file = '', $func = '', $line = '') |
|
313 | - { |
|
314 | - $file_bits = explode('.', basename($file)); |
|
315 | - $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
316 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
317 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
318 | - return $error_code; |
|
319 | - } |
|
302 | + /** |
|
303 | + * create error code from filepath, function name, |
|
304 | + * and line number where exception or error was thrown |
|
305 | + * |
|
306 | + * @access protected |
|
307 | + * @param string $file |
|
308 | + * @param string $func |
|
309 | + * @param string $line |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + protected function generate_error_code($file = '', $func = '', $line = '') |
|
313 | + { |
|
314 | + $file_bits = explode('.', basename($file)); |
|
315 | + $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
316 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
317 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
318 | + return $error_code; |
|
319 | + } |
|
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - /** |
|
324 | - * _exception_styles |
|
325 | - * |
|
326 | - * @return string |
|
327 | - */ |
|
328 | - private function exceptionStyles() |
|
329 | - { |
|
330 | - return ' |
|
323 | + /** |
|
324 | + * _exception_styles |
|
325 | + * |
|
326 | + * @return string |
|
327 | + */ |
|
328 | + private function exceptionStyles() |
|
329 | + { |
|
330 | + return ' |
|
331 | 331 | <style type="text/css"> |
332 | 332 | #ee-error-message { |
333 | 333 | max-width:90% !important; |
@@ -384,30 +384,30 @@ discard block |
||
384 | 384 | color: #999; |
385 | 385 | } |
386 | 386 | </style>'; |
387 | - } |
|
387 | + } |
|
388 | 388 | |
389 | 389 | |
390 | 390 | |
391 | - /** |
|
392 | - * _print_scripts |
|
393 | - * |
|
394 | - * @param bool $force_print |
|
395 | - * @return string |
|
396 | - */ |
|
397 | - private function printScripts($force_print = false) |
|
398 | - { |
|
399 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
400 | - if (wp_script_is('ee_error_js', 'enqueued')) { |
|
401 | - return ''; |
|
402 | - } |
|
403 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
404 | - wp_enqueue_style('espresso_default'); |
|
405 | - wp_enqueue_style('espresso_custom_css'); |
|
406 | - wp_enqueue_script( 'ee_error_js' ); |
|
391 | + /** |
|
392 | + * _print_scripts |
|
393 | + * |
|
394 | + * @param bool $force_print |
|
395 | + * @return string |
|
396 | + */ |
|
397 | + private function printScripts($force_print = false) |
|
398 | + { |
|
399 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
400 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
401 | + return ''; |
|
402 | + } |
|
403 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
404 | + wp_enqueue_style('espresso_default'); |
|
405 | + wp_enqueue_style('espresso_custom_css'); |
|
406 | + wp_enqueue_script( 'ee_error_js' ); |
|
407 | 407 | wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) ); |
408 | - } |
|
409 | - } else { |
|
410 | - return ' |
|
408 | + } |
|
409 | + } else { |
|
410 | + return ' |
|
411 | 411 | <script> |
412 | 412 | /* <![CDATA[ */ |
413 | 413 | var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
418 | 418 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
419 | 419 | '; |
420 | - } |
|
421 | - return ''; |
|
422 | - } |
|
420 | + } |
|
421 | + return ''; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | |
425 | 425 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use ReflectionClass; |
7 | 7 | use ReflectionException; |
8 | 8 | |
9 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | 10 | exit('No direct script access allowed'); |
11 | 11 | } |
12 | 12 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $output = $this->exceptionStyles(); |
61 | 61 | $output .= ' |
62 | 62 | <div id="ee-error-message" class="error">'; |
63 | - if (! WP_DEBUG) { |
|
63 | + if ( ! WP_DEBUG) { |
|
64 | 64 | $output .= ' |
65 | 65 | <p>'; |
66 | 66 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | <th scope="col" align="right" style="width:2.5%;">#</th> |
79 | 79 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
80 | 80 | <th scope="col" align="left" style="width:40%;">File</th> |
81 | - <th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __('Method( arguments )', |
|
82 | - 'event_espresso') . '</th> |
|
81 | + <th scope="col" align="left">' . __('Class', 'event_espresso').'->'.__('Method( arguments )', |
|
82 | + 'event_espresso').'</th> |
|
83 | 83 | </tr>'; |
84 | 84 | $last_on_stack = count($trace) - 1; |
85 | 85 | // reverse array so that stack is in proper chronological order |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $type = isset($trace['type']) ? $trace['type'] : ''; |
91 | 91 | $function = isset($trace['function']) ? $trace['function'] : ''; |
92 | 92 | $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
93 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
93 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args; |
|
94 | 94 | $line = isset($trace['line']) ? $trace['line'] : ''; |
95 | 95 | $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
96 | 96 | if (empty($file) && ! empty($class)) { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $class_display = ! empty($class) ? $class : ''; |
114 | 114 | $type = ! empty($type) ? $type : ''; |
115 | 115 | $function = ! empty($function) ? $function : ''; |
116 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
116 | + $args = ! empty($args) ? '( '.$args.' )' : '()'; |
|
117 | 117 | $trace_details .= ' |
118 | 118 | <tr> |
119 | 119 | <td align="right" valign="top" class="' |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $code = $exception->getCode() ? $exception->getCode() : $error_code; |
149 | 149 | // add generic non-identifying messages for non-privileged users |
150 | - if (! WP_DEBUG) { |
|
150 | + if ( ! WP_DEBUG) { |
|
151 | 151 | $output .= '<span class="ee-error-user-msg-spn">' |
152 | 152 | . trim($msg) |
153 | 153 | . '</span> <sup>' |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | '<strong class="ee-error-dev-msg-str">', |
165 | 165 | get_class($exception), |
166 | 166 | '</strong> <span>', |
167 | - $code . '</span>' |
|
167 | + $code.'</span>' |
|
168 | 168 | ) |
169 | 169 | . '<br /> |
170 | 170 | <span class="big-text">"' |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | . '-dv" class="ee-error-trace-dv" style="display: none;"> |
195 | 195 | ' |
196 | 196 | . $trace_details; |
197 | - if (! empty($class)) { |
|
197 | + if ( ! empty($class)) { |
|
198 | 198 | $output .= ' |
199 | 199 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
200 | 200 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
201 | - <h3>' . __('Class Details', 'event_espresso') . '</h3>'; |
|
201 | + <h3>' . __('Class Details', 'event_espresso').'</h3>'; |
|
202 | 202 | $a = new ReflectionClass($class); |
203 | 203 | $output .= ' |
204 | - <pre>' . $a . '</pre> |
|
204 | + <pre>' . $a.'</pre> |
|
205 | 205 | </div> |
206 | 206 | </div>'; |
207 | 207 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | // remove last linebreak |
214 | 214 | $output = substr($output, 0, -6); |
215 | - if (! WP_DEBUG) { |
|
215 | + if ( ! WP_DEBUG) { |
|
216 | 216 | $output .= ' |
217 | 217 | </p>'; |
218 | 218 | } |
@@ -251,25 +251,25 @@ discard block |
||
251 | 251 | $args[] = ' '; |
252 | 252 | } |
253 | 253 | if (is_string($arg)) { |
254 | - if (! $array && strlen($arg) > 75) { |
|
254 | + if ( ! $array && strlen($arg) > 75) { |
|
255 | 255 | $args[] = '<br />'; |
256 | 256 | for ($i = 0; $i <= $indent; $i++) { |
257 | 257 | $args[] = ' '; |
258 | 258 | } |
259 | - $args[] = "'" . $arg . "'<br />"; |
|
259 | + $args[] = "'".$arg."'<br />"; |
|
260 | 260 | } else { |
261 | - $args[] = " '" . $arg . "'"; |
|
261 | + $args[] = " '".$arg."'"; |
|
262 | 262 | } |
263 | 263 | } elseif (is_array($arg)) { |
264 | 264 | $arg_count = count($arg); |
265 | 265 | if ($arg_count > 2) { |
266 | 266 | $indent++; |
267 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
267 | + $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')'; |
|
268 | 268 | $indent--; |
269 | 269 | } else if ($arg_count === 0) { |
270 | 270 | $args[] = ' array()'; |
271 | 271 | } else { |
272 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
272 | + $args[] = ' array( '.$this->_convert_args_to_string($arg).' )'; |
|
273 | 273 | } |
274 | 274 | } elseif ($arg === null) { |
275 | 275 | $args[] = ' null'; |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | { |
314 | 314 | $file_bits = explode('.', basename($file)); |
315 | 315 | $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
316 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
317 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
316 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
317 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
318 | 318 | return $error_code; |
319 | 319 | } |
320 | 320 | |
@@ -396,26 +396,26 @@ discard block |
||
396 | 396 | */ |
397 | 397 | private function printScripts($force_print = false) |
398 | 398 | { |
399 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
399 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
400 | 400 | if (wp_script_is('ee_error_js', 'enqueued')) { |
401 | 401 | return ''; |
402 | 402 | } |
403 | 403 | if (wp_script_is('ee_error_js', 'registered')) { |
404 | 404 | wp_enqueue_style('espresso_default'); |
405 | 405 | wp_enqueue_style('espresso_custom_css'); |
406 | - wp_enqueue_script( 'ee_error_js' ); |
|
407 | - wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) ); |
|
406 | + wp_enqueue_script('ee_error_js'); |
|
407 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
408 | 408 | } |
409 | 409 | } else { |
410 | 410 | return ' |
411 | 411 | <script> |
412 | 412 | /* <![CDATA[ */ |
413 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
413 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
414 | 414 | /* ]]> */ |
415 | 415 | </script> |
416 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
417 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
418 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
416 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
417 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
418 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
419 | 419 | '; |
420 | 420 | } |
421 | 421 | return ''; |