@@ -8,8 +8,8 @@ |
||
8 | 8 | foreach( $form_section->subsections() as $subsection ) { |
9 | 9 | if( $subsection instanceof EE_Form_Input_Base ) { |
10 | 10 | if( $subsection->get_sensitive_data_removal_strategy() instanceof EE_All_Sensitive_Data_Removal |
11 | - || $subsection->get_sensitive_data_removal_strategy() instanceof EE_CCV_Sensitive_Data_Removal |
|
12 | - || $subsection->get_display_strategy() instanceof EE_Hidden_Display_Strategy ){ |
|
11 | + || $subsection->get_sensitive_data_removal_strategy() instanceof EE_CCV_Sensitive_Data_Removal |
|
12 | + || $subsection->get_display_strategy() instanceof EE_Hidden_Display_Strategy ){ |
|
13 | 13 | continue; |
14 | 14 | } |
15 | 15 | if( $subsection->get_sensitive_data_removal_strategy() instanceof EE_Credit_Card_Sensitive_Data_Removal ) { |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <div id="admin-side-mbox-billing-info-dv" class="admin-side-mbox-dv"> |
2 | -<?php if ( empty($billing_form) ) : ?> |
|
2 | +<?php if (empty($billing_form)) : ?> |
|
3 | 3 | <div class="clearfix"> |
4 | - <?php _e( 'There is no billing info for this transaction.', 'event_espresso' );?><br/> |
|
4 | + <?php _e('There is no billing info for this transaction.', 'event_espresso'); ?><br/> |
|
5 | 5 | </div> |
6 | 6 | <?php else : |
7 | - function ee_show_billing_info_cleaned( EE_Form_Section_Proper $form_section, $found_cc_data = false ) { |
|
8 | - foreach( $form_section->subsections() as $subsection ) { |
|
9 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
10 | - if( $subsection->get_sensitive_data_removal_strategy() instanceof EE_All_Sensitive_Data_Removal |
|
7 | + function ee_show_billing_info_cleaned(EE_Form_Section_Proper $form_section, $found_cc_data = false) { |
|
8 | + foreach ($form_section->subsections() as $subsection) { |
|
9 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
10 | + if ($subsection->get_sensitive_data_removal_strategy() instanceof EE_All_Sensitive_Data_Removal |
|
11 | 11 | || $subsection->get_sensitive_data_removal_strategy() instanceof EE_CCV_Sensitive_Data_Removal |
12 | - || $subsection->get_display_strategy() instanceof EE_Hidden_Display_Strategy ){ |
|
12 | + || $subsection->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
13 | 13 | continue; |
14 | 14 | } |
15 | - if( $subsection->get_sensitive_data_removal_strategy() instanceof EE_Credit_Card_Sensitive_Data_Removal ) { |
|
15 | + if ($subsection->get_sensitive_data_removal_strategy() instanceof EE_Credit_Card_Sensitive_Data_Removal) { |
|
16 | 16 | $found_cc_data = true; |
17 | 17 | } |
18 | 18 | ?> |
19 | 19 | <div class="clearfix"> |
20 | - <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php echo $subsection->get_html_for_label();?></span><?php echo $subsection->pretty_value();?> |
|
20 | + <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php echo $subsection->get_html_for_label(); ?></span><?php echo $subsection->pretty_value(); ?> |
|
21 | 21 | </div><?php |
22 | - } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
23 | - $found_cc_data = ee_show_billing_info_cleaned( $subsection, $found_cc_data); |
|
22 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
23 | + $found_cc_data = ee_show_billing_info_cleaned($subsection, $found_cc_data); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | return $found_cc_data; |
27 | 27 | } |
28 | - $found_cc_data = ee_show_billing_info_cleaned( $billing_form ); |
|
29 | - if( apply_filters( |
|
28 | + $found_cc_data = ee_show_billing_info_cleaned($billing_form); |
|
29 | + if (apply_filters( |
|
30 | 30 | 'FHEE__txn_admin_details_side_meta_box_billing_info__show_default_note', |
31 | 31 | $found_cc_data, |
32 | - $billing_form ) ) {?> |
|
33 | - <p class="help"><?php _e( 'Note: Card expiry dates and CCV are not stored. Only the last 4 digits of card numbers are stored.', 'event_espresso' );?></p> |
|
32 | + $billing_form )) {?> |
|
33 | + <p class="help"><?php _e('Note: Card expiry dates and CCV are not stored. Only the last 4 digits of card numbers are stored.', 'event_espresso'); ?></p> |
|
34 | 34 | <?php } |
35 | - do_action( 'AHEE__txn_admin_details_side_meta_box_billing_info__billing_form_footer', $billing_form ); |
|
35 | + do_action('AHEE__txn_admin_details_side_meta_box_billing_info__billing_form_footer', $billing_form); |
|
36 | 36 | endif; ?> |
37 | 37 | |
38 | 38 | </div> |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
6 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
5 | +if ( ! class_exists('WP_List_Table')) { |
|
6 | + require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | /** |
207 | 207 | * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table |
208 | 208 | */ |
209 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
209 | + public function __construct(EE_Admin_Page $admin_page) { |
|
210 | 210 | $this->_admin_page = $admin_page; |
211 | 211 | $this->_req_data = $this->_admin_page->get_request_data(); |
212 | 212 | $this->_view = $this->_admin_page->get_view(); |
213 | - $this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
213 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
214 | 214 | $this->_current_page = $this->get_pagenum(); |
215 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
216 | - $this->_yes_no = array( __('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
215 | + $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view(); |
|
216 | + $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
217 | 217 | |
218 | - $this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 ); |
|
218 | + $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10); |
|
219 | 219 | |
220 | 220 | $this->_setup_data(); |
221 | 221 | $this->_add_view_counts(); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $this->_set_properties(); |
226 | 226 | |
227 | 227 | //set primary column |
228 | - add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) ); |
|
228 | + add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
229 | 229 | |
230 | 230 | //set parent defaults |
231 | 231 | parent::__construct($this->_wp_list_args); |
@@ -301,17 +301,17 @@ discard block |
||
301 | 301 | * @return string |
302 | 302 | */ |
303 | 303 | protected function _get_hidden_fields() { |
304 | - $action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : ''; |
|
305 | - $action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action; |
|
304 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
305 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
306 | 306 | //if action is STILL empty, then we set it to default |
307 | - $action = empty( $action ) ? 'default' : $action; |
|
308 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
309 | - $field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/ |
|
310 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
307 | + $action = empty($action) ? 'default' : $action; |
|
308 | + $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n"; |
|
309 | + $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/ |
|
310 | + $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n"; |
|
311 | 311 | |
312 | 312 | $bulk_actions = $this->_get_bulk_actions(); |
313 | - foreach ( $bulk_actions as $bulk_action => $label ) { |
|
314 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce ( $bulk_action . '_nonce' ) . '" />' . "\n"; |
|
313 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
314 | + $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n"; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | return $field; |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @var array |
343 | 343 | */ |
344 | - $_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen ); |
|
344 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
345 | 345 | |
346 | 346 | $sortable = array(); |
347 | - foreach ( $_sortable as $id => $data ) { |
|
348 | - if ( empty( $data ) ) { |
|
347 | + foreach ($_sortable as $id => $data) { |
|
348 | + if (empty($data)) { |
|
349 | 349 | continue; |
350 | 350 | } |
351 | 351 | //fix for offset errors with WP_List_Table default get_columninfo() |
352 | - if ( is_array($data) ) { |
|
352 | + if (is_array($data)) { |
|
353 | 353 | $_data[0] = key($data); |
354 | 354 | $_data[1] = isset($data[1]) ? $data[1] : false; |
355 | 355 | } else { |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | |
359 | 359 | $data = (array) $data; |
360 | 360 | |
361 | - if ( !isset( $data[1] ) ) { |
|
361 | + if ( ! isset($data[1])) { |
|
362 | 362 | $_data[1] = false; |
363 | 363 | } |
364 | 364 | |
365 | 365 | $sortable[$id] = $_data; |
366 | 366 | } |
367 | 367 | $primary = $this->get_primary_column_name(); |
368 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
368 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | * @return string |
375 | 375 | */ |
376 | 376 | protected function get_primary_column_name() { |
377 | - foreach( class_parents( $this ) as $parent ) { |
|
378 | - if ( $parent === 'WP_List_Table' && method_exists( $parent, 'get_primary_column_name' ) ) { |
|
377 | + foreach (class_parents($this) as $parent) { |
|
378 | + if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) { |
|
379 | 379 | return parent::get_primary_column_name(); |
380 | 380 | } |
381 | 381 | } |
@@ -392,10 +392,10 @@ discard block |
||
392 | 392 | * @param string $primary |
393 | 393 | * @return string |
394 | 394 | */ |
395 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
396 | - foreach( class_parents( $this ) as $parent ) { |
|
397 | - if ( $parent === 'WP_List_Table' && method_exists( $parent, 'handle_row_actions' ) ) { |
|
398 | - return parent::handle_row_actions( $item, $column_name, $primary ); |
|
395 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
396 | + foreach (class_parents($this) as $parent) { |
|
397 | + if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) { |
|
398 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | return ''; |
@@ -413,11 +413,11 @@ discard block |
||
413 | 413 | protected function _get_bulk_actions() { |
414 | 414 | $actions = array(); |
415 | 415 | //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
416 | - foreach ( $this->_views as $view => $args) { |
|
417 | - if ( $this->_view === $view && isset( $args['bulk_action']) && is_array($args['bulk_action']) ) { |
|
416 | + foreach ($this->_views as $view => $args) { |
|
417 | + if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) { |
|
418 | 418 | //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
419 | - foreach ( $args['bulk_action'] as $route =>$label ) { |
|
420 | - if ( $this->_admin_page->check_user_access( $route, true ) ) { |
|
419 | + foreach ($args['bulk_action'] as $route =>$label) { |
|
420 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
421 | 421 | $actions[$route] = $label; |
422 | 422 | } |
423 | 423 | } |
@@ -436,18 +436,18 @@ discard block |
||
436 | 436 | */ |
437 | 437 | private function _filters() { |
438 | 438 | $classname = get_class($this); |
439 | - $filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen ); |
|
439 | + $filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen); |
|
440 | 440 | |
441 | - if ( empty( $filters )) { |
|
441 | + if (empty($filters)) { |
|
442 | 442 | return; |
443 | 443 | } |
444 | - foreach ( $filters as $filter ) { |
|
444 | + foreach ($filters as $filter) { |
|
445 | 445 | echo $filter; |
446 | 446 | } |
447 | 447 | //add filter button at end |
448 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />'; |
|
448 | + echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />'; |
|
449 | 449 | //add reset filters button at end |
450 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>'; |
|
450 | + echo '<a class="button button-secondary" href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>'; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @param string $column_name |
462 | 462 | * @return string |
463 | 463 | */ |
464 | - public function set_primary_column( $column_name ) { |
|
465 | - return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name; |
|
464 | + public function set_primary_column($column_name) { |
|
465 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | array( |
483 | 483 | 'total_items' => $total_items, |
484 | 484 | 'per_page' => $this->_per_page, |
485 | - 'total_pages' => ceil($total_items / $this->_per_page ) |
|
485 | + 'total_pages' => ceil($total_items / $this->_per_page) |
|
486 | 486 | ) |
487 | 487 | ); |
488 | 488 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @param string $column_name The column being called. |
497 | 497 | * @return string html content for the column |
498 | 498 | */ |
499 | - public function column_default( $item, $column_name ) { |
|
499 | + public function column_default($item, $column_name) { |
|
500 | 500 | /** |
501 | 501 | * Dynamic hook allowing for adding additional column content in this list table. |
502 | 502 | * Note that $this->screen->id is in the format |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * hook prefix ("event-espresso") will be different. |
507 | 507 | * |
508 | 508 | */ |
509 | - do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen ); |
|
509 | + do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @var array |
534 | 534 | */ |
535 | - $columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen ); |
|
535 | + $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen); |
|
536 | 536 | return $columns; |
537 | 537 | } |
538 | 538 | |
@@ -555,18 +555,18 @@ discard block |
||
555 | 555 | $views = $this->get_views(); |
556 | 556 | $assembled_views = ''; |
557 | 557 | |
558 | - if ( empty( $views )) { |
|
558 | + if (empty($views)) { |
|
559 | 559 | return; |
560 | 560 | } |
561 | 561 | echo "<ul class='subsubsub'>\n"; |
562 | - foreach ( $views as $view ) { |
|
563 | - $count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] ) : 0; |
|
564 | - if ( isset( $view['slug'], $view['class'], $view['url'], $view['label']) ) { |
|
565 | - $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
562 | + foreach ($views as $view) { |
|
563 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
564 | + if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) { |
|
565 | + $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>'; |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | |
569 | - echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : ''; |
|
569 | + echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : ''; |
|
570 | 570 | echo "</ul>"; |
571 | 571 | } |
572 | 572 | |
@@ -578,10 +578,10 @@ discard block |
||
578 | 578 | * @access public |
579 | 579 | * @param EE_Base_Class $item The current item |
580 | 580 | */ |
581 | - public function single_row( $item ) { |
|
582 | - $row_class = $this->_get_row_class( $item ); |
|
583 | - echo '<tr class="' . esc_attr( $row_class ) . '">'; |
|
584 | - $this->single_row_columns( $item ); |
|
581 | + public function single_row($item) { |
|
582 | + $row_class = $this->_get_row_class($item); |
|
583 | + echo '<tr class="'.esc_attr($row_class).'">'; |
|
584 | + $this->single_row_columns($item); |
|
585 | 585 | echo '</tr>'; |
586 | 586 | } |
587 | 587 | |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | * @param EE_Base_Class $item the current item |
594 | 594 | * @return string |
595 | 595 | */ |
596 | - protected function _get_row_class( $item ) { |
|
596 | + protected function _get_row_class($item) { |
|
597 | 597 | static $row_class = ''; |
598 | - $row_class = ( $row_class === '' ? 'alternate' : '' ); |
|
598 | + $row_class = ($row_class === '' ? 'alternate' : ''); |
|
599 | 599 | |
600 | 600 | $new_row_class = $row_class; |
601 | 601 | |
602 | - if ( !empty($this->_ajax_sorting_callback) ) { |
|
602 | + if ( ! empty($this->_ajax_sorting_callback)) { |
|
603 | 603 | $new_row_class .= ' rowsortable'; |
604 | 604 | } |
605 | 605 | |
@@ -631,13 +631,13 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public function get_hidden_columns() { |
633 | 633 | $user_id = get_current_user_id(); |
634 | - $has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id); |
|
635 | - if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) { |
|
636 | - update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE); |
|
637 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE ); |
|
634 | + $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id); |
|
635 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
636 | + update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE); |
|
637 | + update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE); |
|
638 | 638 | } |
639 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
640 | - return (array) get_user_option( $ref, $user_id ); |
|
639 | + $ref = 'manage'.$this->screen->id.'columnshidden'; |
|
640 | + return (array) get_user_option($ref, $user_id); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -650,47 +650,47 @@ discard block |
||
650 | 650 | * @since 3.1.0 |
651 | 651 | * @param EE_Base_Class $item The current item |
652 | 652 | */ |
653 | - public function single_row_columns( $item ) { |
|
654 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
653 | + public function single_row_columns($item) { |
|
654 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
655 | 655 | |
656 | 656 | global $wp_version; |
657 | - $use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' ); |
|
657 | + $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
658 | 658 | |
659 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
659 | + foreach ($columns as $column_name => $column_display_name) { |
|
660 | 660 | |
661 | 661 | /** |
662 | 662 | * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
663 | 663 | * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
664 | 664 | */ |
665 | - $hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : ''; |
|
666 | - $style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : ''; |
|
665 | + $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
666 | + $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
667 | 667 | |
668 | - $classes = $column_name . ' column-' . $column_name.$hidden_class; |
|
669 | - if ( $primary === $column_name ) { |
|
668 | + $classes = $column_name.' column-'.$column_name.$hidden_class; |
|
669 | + if ($primary === $column_name) { |
|
670 | 670 | $classes .= ' has-row-actions column-primary'; |
671 | 671 | } |
672 | 672 | |
673 | - $data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
673 | + $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
674 | 674 | |
675 | 675 | $class = "class='$classes'"; |
676 | 676 | |
677 | 677 | $attributes = "$class$style$data"; |
678 | 678 | |
679 | - if ( $column_name === 'cb' ) { |
|
679 | + if ($column_name === 'cb') { |
|
680 | 680 | echo '<th scope="row" class="check-column">'; |
681 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
|
681 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this); |
|
682 | 682 | echo '</th>'; |
683 | 683 | } |
684 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
684 | + elseif (method_exists($this, 'column_'.$column_name)) { |
|
685 | 685 | echo "<td $attributes>"; |
686 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
|
687 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
686 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', call_user_func(array($this, 'column_'.$column_name), $item), $item, $this); |
|
687 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
688 | 688 | echo "</td>"; |
689 | 689 | } |
690 | 690 | else { |
691 | 691 | echo "<td $attributes>"; |
692 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
|
693 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
692 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default($item, $column_name), $item, $column_name, $this); |
|
693 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
694 | 694 | echo "</td>"; |
695 | 695 | } |
696 | 696 | } |
@@ -705,15 +705,15 @@ discard block |
||
705 | 705 | * @param string $which |
706 | 706 | * @throws \EE_Error |
707 | 707 | */ |
708 | - public function extra_tablenav( $which ) { |
|
709 | - if ( $which === 'top' ) { |
|
708 | + public function extra_tablenav($which) { |
|
709 | + if ($which === 'top') { |
|
710 | 710 | $this->_filters(); |
711 | 711 | echo $this->_get_hidden_fields(); |
712 | 712 | } else { |
713 | 713 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
714 | - foreach ( $this->_bottom_buttons as $type => $action ){ |
|
715 | - $route = isset( $action['route'] ) ? $action['route'] : ''; |
|
716 | - $extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : ''; |
|
714 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
715 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
716 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
717 | 717 | echo $this->_admin_page->get_action_link_or_button( |
718 | 718 | $route, |
719 | 719 | $type, |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | false |
724 | 724 | ); |
725 | 725 | } |
726 | - do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen ); |
|
726 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
727 | 727 | echo '</div>'; |
728 | 728 | } |
729 | 729 | //echo $this->_entries_per_page_dropdown; |
@@ -779,11 +779,11 @@ discard block |
||
779 | 779 | * the actions. |
780 | 780 | * @return string The assembled action elements container. |
781 | 781 | */ |
782 | - protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) { |
|
782 | + protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') { |
|
783 | 783 | $content = ''; |
784 | - $action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : ''; |
|
785 | - $action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : ''; |
|
786 | - $content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
784 | + $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : ''; |
|
785 | + $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : ''; |
|
786 | + $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : ''; |
|
787 | 787 | try { |
788 | 788 | $content .= apply_filters( |
789 | 789 | 'FHEE__EE_Admin_List_Table___action_string__action_items', |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | ); |
794 | 794 | } catch (\Exception $e) { |
795 | 795 | if (WP_DEBUG) { |
796 | - \EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
796 | + \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
797 | 797 | } |
798 | 798 | $content .= $action_items; |
799 | 799 | } |
800 | - $content .= ! empty( $action_container ) ? '</' . $action_container . '>' : ''; |
|
800 | + $content .= ! empty($action_container) ? '</'.$action_container.'>' : ''; |
|
801 | 801 | return $content; |
802 | 802 | } |
803 | 803 | } |
@@ -680,14 +680,12 @@ |
||
680 | 680 | echo '<th scope="row" class="check-column">'; |
681 | 681 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
682 | 682 | echo '</th>'; |
683 | - } |
|
684 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
683 | + } elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
685 | 684 | echo "<td $attributes>"; |
686 | 685 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
687 | 686 | echo $this->handle_row_actions( $item, $column_name, $primary ); |
688 | 687 | echo "</td>"; |
689 | - } |
|
690 | - else { |
|
688 | + } else { |
|
691 | 689 | echo "<td $attributes>"; |
692 | 690 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
693 | 691 | echo $this->handle_row_actions( $item, $column_name, $primary ); |
@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | * @param EE_Response $response |
23 | 23 | * @return EE_Response |
24 | 24 | */ |
25 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
25 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
26 | 26 | $this->_request = $request; |
27 | 27 | $this->_response = $response; |
28 | 28 | //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
29 | 29 | //$this->_response->set_notice( 1, 'hey look at this' ); |
30 | 30 | // check required WP version |
31 | - if ( ! $this->_minimum_wp_version_required() ) { |
|
32 | - $this->_request->un_set( 'activate', true ); |
|
33 | - add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 ); |
|
31 | + if ( ! $this->_minimum_wp_version_required()) { |
|
32 | + $this->_request->un_set('activate', true); |
|
33 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
34 | 34 | //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
35 | 35 | $this->_response->terminate_request(); |
36 | 36 | $this->_response->deactivate_plugin(); |
37 | 37 | } |
38 | 38 | // check required PHP version |
39 | - if ( ! $this->_minimum_php_version_required() ) { |
|
40 | - $this->_request->un_set( 'activate', true ); |
|
41 | - add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 ); |
|
39 | + if ( ! $this->_minimum_php_version_required()) { |
|
40 | + $this->_request->un_set('activate', true); |
|
41 | + add_action('admin_notices', array($this, 'minimum_php_version_error'), 1); |
|
42 | 42 | //$this->_response->add_output( "\n<br />" . 'minimum_php_version_error' ); |
43 | 43 | $this->_response->terminate_request(); |
44 | 44 | $this->_response->deactivate_plugin(); |
45 | 45 | } |
46 | 46 | // check recommended PHP version |
47 | - if ( ! $this->_minimum_php_version_recommended() ) { |
|
47 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
48 | 48 | $this->_display_minimum_recommended_php_version_notice(); |
49 | 49 | } |
50 | - $this->_response = $this->process_request_stack( $this->_request, $this->_response ); |
|
50 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
51 | 51 | //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
52 | 52 | return $this->_response; |
53 | 53 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param string $min_version |
62 | 62 | * @return boolean |
63 | 63 | */ |
64 | - private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) { |
|
64 | + private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) { |
|
65 | 65 | global $wp_version; |
66 | - return version_compare( $wp_version, $min_version, '>=' ) ? true : false; |
|
66 | + return version_compare($wp_version, $min_version, '>=') ? true : false; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @return boolean |
76 | 76 | */ |
77 | 77 | private function _minimum_wp_version_required() { |
78 | - return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED ); |
|
78 | + return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @param string $min_version |
88 | 88 | * @return boolean |
89 | 89 | */ |
90 | - private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) { |
|
91 | - return version_compare( PHP_VERSION, $min_version, '>=' ) ? true : false; |
|
90 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) { |
|
91 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | 102 | private function _minimum_php_version_required() { |
103 | - return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED ); |
|
103 | + return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return boolean |
113 | 113 | */ |
114 | 114 | private function _minimum_php_version_recommended() { |
115 | - return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED ); |
|
115 | + return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | <p> |
130 | 130 | <?php |
131 | 131 | printf( |
132 | - __( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
132 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
133 | 133 | EE_MIN_WP_VER_REQUIRED, |
134 | 134 | $wp_version, |
135 | 135 | '<br/>', |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | private function _display_minimum_recommended_php_version_notice() { |
154 | 154 | EE_Error::add_persistent_admin_notice( |
155 | - 'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended', |
|
155 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
156 | 156 | sprintf( |
157 | - __( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
157 | + __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
158 | 158 | EE_MIN_PHP_VER_RECOMMENDED, |
159 | 159 | PHP_VERSION, |
160 | 160 | '<br/>', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->_columns = array_merge( $columns, $this->_columns ); |
88 | 88 | $this->_primary_column = '_REG_att_checked_in'; |
89 | 89 | if ( ! empty( $evt_id ) |
90 | - && EE_Registry::instance()->CAP->current_user_can( |
|
90 | + && EE_Registry::instance()->CAP->current_user_can( |
|
91 | 91 | 'ee_read_registrations', |
92 | 92 | 'espresso_registrations_registrations_reports', |
93 | 93 | $evt_id |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | if ( count( $this->_dtts_for_event ) > 1 ) { |
190 | 190 | $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
191 | 191 | foreach ( $this->_dtts_for_event as $dtt ) { |
192 | - $datetime_string = $dtt->name(); |
|
193 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
192 | + $datetime_string = $dtt->name(); |
|
193 | + $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
194 | 194 | $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
195 | 195 | $dtts[ $dtt->ID() ] = $datetime_string; |
196 | 196 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id ); |
285 | 285 | $nonce = wp_create_nonce( 'checkin_nonce' ); |
286 | 286 | $toggle_active = ! empty ( $this->_cur_dtt_id ) |
287 | - && EE_Registry::instance()->CAP->current_user_can( |
|
287 | + && EE_Registry::instance()->CAP->current_user_can( |
|
288 | 288 | 'ee_edit_checkin', |
289 | 289 | 'espresso_registrations_toggle_checkin_status', |
290 | 290 | $item->ID() |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | : ''; |
294 | 294 | $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
295 | 295 | return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"' |
296 | - . ' data-_regid="' . $item->ID() . '"' |
|
297 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
298 | - . ' data-nonce="' . $nonce . '">' |
|
299 | - . '</span>' |
|
300 | - . $mobile_view_content; |
|
296 | + . ' data-_regid="' . $item->ID() . '"' |
|
297 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
298 | + . ' data-nonce="' . $nonce . '">' |
|
299 | + . '</span>' |
|
300 | + . $mobile_view_content; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | 'espresso_registrations_edit_attendee' |
323 | 323 | ) |
324 | 324 | ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' |
325 | - . $item->attendee()->full_name() |
|
326 | - . '</a>' |
|
325 | + . $item->attendee()->full_name() |
|
326 | + . '</a>' |
|
327 | 327 | : $item->attendee()->full_name(); |
328 | 328 | $name_link .= $item->count() === 1 |
329 | 329 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | ? $latest_related_datetime->ID() |
359 | 359 | : $DTT_ID; |
360 | 360 | if ( ! empty( $DTT_ID ) |
361 | - && EE_Registry::instance()->CAP->current_user_can( |
|
361 | + && EE_Registry::instance()->CAP->current_user_can( |
|
362 | 362 | 'ee_read_checkins', |
363 | 363 | 'espresso_registrations_registration_checkins' |
364 | 364 | ) |
@@ -458,15 +458,15 @@ discard block |
||
458 | 458 | ) ? ' |
459 | 459 | <span class="reg-pad-rght"> |
460 | 460 | <a class="status-' |
461 | - . $item->transaction()->status_ID() |
|
462 | - . '" href="' |
|
463 | - . $view_txn_lnk_url |
|
464 | - . '" title="' |
|
465 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
466 | - . '"> |
|
461 | + . $item->transaction()->status_ID() |
|
462 | + . '" href="' |
|
463 | + . $view_txn_lnk_url |
|
464 | + . '" title="' |
|
465 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
466 | + . '"> |
|
467 | 467 | ' |
468 | - . $item->transaction()->pretty_paid() |
|
469 | - . ' |
|
468 | + . $item->transaction()->pretty_paid() |
|
469 | + . ' |
|
470 | 470 | </a> |
471 | 471 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
472 | 472 | } |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | 'ee_read_transaction', |
500 | 500 | 'espresso_transactions_view_transaction' |
501 | 501 | ) ? '<a href="' |
502 | - . $view_txn_url |
|
503 | - . '" title="' |
|
504 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
505 | - . '"><span class="reg-pad-rght">' |
|
506 | - . $txn_total |
|
507 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
502 | + . $view_txn_url |
|
503 | + . '" title="' |
|
504 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
505 | + . '"><span class="reg-pad-rght">' |
|
506 | + . $txn_total |
|
507 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
508 | 508 | } else { |
509 | 509 | return '<span class="reg-pad-rght"></span>'; |
510 | 510 | } |
@@ -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,18 +99,18 @@ 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 | ); |
106 | 106 | } |
107 | 107 | $this->_sortable_columns = array( |
108 | 108 | //true means its already sorted |
109 | - 'ATT_name' => array( 'ATT_name' => true ), |
|
110 | - 'Event' => array( 'Event.EVT.Name' => false ), |
|
109 | + 'ATT_name' => array('ATT_name' => true), |
|
110 | + 'Event' => array('Event.EVT.Name' => false), |
|
111 | 111 | ); |
112 | 112 | $this->_hidden_columns = array(); |
113 | - $this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id ); |
|
113 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
114 | 114 | $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
115 | 115 | } |
116 | 116 | |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * @param \EE_Registration $item |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - protected function _get_row_class( $item ) { |
|
124 | - $class = parent::_get_row_class( $item ); |
|
123 | + protected function _get_row_class($item) { |
|
124 | + $class = parent::_get_row_class($item); |
|
125 | 125 | //add status class |
126 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
127 | - if ( $this->_has_checkbox_column ) { |
|
126 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
127 | + if ($this->_has_checkbox_column) { |
|
128 | 128 | $class .= ' has-checkbox-column'; |
129 | 129 | } |
130 | 130 | return $class; |
@@ -138,61 +138,61 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function _get_table_filters() { |
140 | 140 | $filters = $where = array(); |
141 | - $current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0; |
|
142 | - if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) { |
|
141 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
142 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
143 | 143 | //this means we don't have an event so let's setup a filter dropdown for all the events to select |
144 | 144 | //note possible capability restrictions |
145 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
146 | - $where['status**'] = array( '!=', 'private' ); |
|
145 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
146 | + $where['status**'] = array('!=', 'private'); |
|
147 | 147 | } |
148 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
148 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
149 | 149 | $where['EVT_wp_user'] = get_current_user_id(); |
150 | 150 | } |
151 | 151 | $events = EEM_Event::instance()->get_all( |
152 | 152 | array( |
153 | 153 | $where, |
154 | - 'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ), |
|
154 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
155 | 155 | ) |
156 | 156 | ); |
157 | 157 | $evts[] = array( |
158 | 158 | 'id' => 0, |
159 | - 'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ), |
|
159 | + 'text' => __('To toggle Check-in status, select an event', 'event_espresso'), |
|
160 | 160 | ); |
161 | 161 | $checked = 'checked'; |
162 | 162 | /** @var EE_Event $evt */ |
163 | - foreach ( $events as $evt ) { |
|
163 | + foreach ($events as $evt) { |
|
164 | 164 | //any registrations for this event? |
165 | - if ( ! $evt->get_count_of_all_registrations() ) { |
|
165 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
166 | 166 | continue; |
167 | 167 | } |
168 | 168 | $evts[] = array( |
169 | 169 | 'id' => $evt->ID(), |
170 | - 'text' => $evt->get( 'EVT_name' ), |
|
170 | + 'text' => $evt->get('EVT_name'), |
|
171 | 171 | 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
172 | 172 | ); |
173 | - if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) { |
|
173 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
174 | 174 | $checked = ''; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | $event_filter = '<div class="ee-event-filter">'; |
178 | - $event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID ); |
|
178 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
179 | 179 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
180 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
181 | - $event_filter .= __( 'Hide Expired Events', 'event_espresso' ); |
|
180 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
181 | + $event_filter .= __('Hide Expired Events', 'event_espresso'); |
|
182 | 182 | $event_filter .= '</span>'; |
183 | 183 | $event_filter .= '</div>'; |
184 | 184 | $filters[] = $event_filter; |
185 | 185 | } |
186 | - if ( ! empty( $this->_dtts_for_event ) ) { |
|
186 | + if ( ! empty($this->_dtts_for_event)) { |
|
187 | 187 | //DTT datetimes filter |
188 | - $this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0; |
|
189 | - if ( count( $this->_dtts_for_event ) > 1 ) { |
|
190 | - $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
|
191 | - foreach ( $this->_dtts_for_event as $dtt ) { |
|
188 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
189 | + if (count($this->_dtts_for_event) > 1) { |
|
190 | + $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
191 | + foreach ($this->_dtts_for_event as $dtt) { |
|
192 | 192 | $datetime_string = $dtt->name(); |
193 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
194 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
195 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
193 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
194 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
195 | + $dtts[$dtt->ID()] = $datetime_string; |
|
196 | 196 | } |
197 | 197 | $input = new EE_Select_Input( |
198 | 198 | $dtts, |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ) |
204 | 204 | ); |
205 | 205 | $filters[] = $input->get_html_for_input(); |
206 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
206 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | return $filters; |
@@ -222,22 +222,22 @@ discard block |
||
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | 224 | protected function _get_total_event_attendees() { |
225 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false; |
|
225 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
226 | 226 | $DTT_ID = $this->_cur_dtt_id; |
227 | 227 | $query_params = array(); |
228 | - if ( $EVT_ID ) { |
|
228 | + if ($EVT_ID) { |
|
229 | 229 | $query_params[0]['EVT_ID'] = $EVT_ID; |
230 | 230 | } |
231 | 231 | //if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
232 | - if ( $DTT_ID ) { |
|
232 | + if ($DTT_ID) { |
|
233 | 233 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
234 | 234 | } |
235 | 235 | $status_ids_array = apply_filters( |
236 | 236 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
237 | - array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) |
|
237 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
238 | 238 | ); |
239 | - $query_params[0]['STS_ID'] = array( 'IN', $status_ids_array ); |
|
240 | - return EEM_Registration::instance()->count( $query_params ); |
|
239 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
240 | + return EEM_Registration::instance()->count($query_params); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @param \EE_Registration $item |
247 | 247 | * @return string |
248 | 248 | */ |
249 | - public function column__Reg_Status( EE_Registration $item ) { |
|
250 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
249 | + public function column__Reg_Status(EE_Registration $item) { |
|
250 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>'; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @return string |
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | - public function column_cb( $item ) { |
|
261 | - return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() ); |
|
260 | + public function column_cb($item) { |
|
261 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -270,20 +270,20 @@ discard block |
||
270 | 270 | * @return string |
271 | 271 | * @throws \EE_Error |
272 | 272 | */ |
273 | - public function column__REG_att_checked_in( EE_Registration $item ) { |
|
273 | + public function column__REG_att_checked_in(EE_Registration $item) { |
|
274 | 274 | $attendee = $item->attendee(); |
275 | 275 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
276 | 276 | |
277 | - if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) { |
|
277 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
278 | 278 | $latest_related_datetime = $item->get_latest_related_datetime(); |
279 | - if ( $latest_related_datetime instanceof EE_Datetime ) { |
|
279 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
280 | 280 | $this->_cur_dtt_id = $latest_related_datetime->ID(); |
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | - $checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id ); |
|
285 | - $nonce = wp_create_nonce( 'checkin_nonce' ); |
|
286 | - $toggle_active = ! empty ( $this->_cur_dtt_id ) |
|
284 | + $checkinstatus = $item->check_in_status_for_datetime($this->_cur_dtt_id); |
|
285 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
286 | + $toggle_active = ! empty ($this->_cur_dtt_id) |
|
287 | 287 | && EE_Registry::instance()->CAP->current_user_can( |
288 | 288 | 'ee_edit_checkin', |
289 | 289 | 'espresso_registrations_toggle_checkin_status', |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | ) |
292 | 292 | ? ' clickable trigger-checkin' |
293 | 293 | : ''; |
294 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
295 | - return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"' |
|
296 | - . ' data-_regid="' . $item->ID() . '"' |
|
297 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
298 | - . ' data-nonce="' . $nonce . '">' |
|
294 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
295 | + return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'"' |
|
296 | + . ' data-_regid="'.$item->ID().'"' |
|
297 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
298 | + . ' data-nonce="'.$nonce.'">' |
|
299 | 299 | . '</span>' |
300 | 300 | . $mobile_view_content; |
301 | 301 | } |
@@ -307,21 +307,21 @@ discard block |
||
307 | 307 | * @return mixed|string|void |
308 | 308 | * @throws \EE_Error |
309 | 309 | */ |
310 | - public function column_ATT_name( EE_Registration $item ) { |
|
310 | + public function column_ATT_name(EE_Registration $item) { |
|
311 | 311 | $attendee = $item->attendee(); |
312 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
313 | - return __( 'No contact record for this registration.', 'event_espresso' ); |
|
312 | + if ( ! $attendee instanceof EE_Attendee) { |
|
313 | + return __('No contact record for this registration.', 'event_espresso'); |
|
314 | 314 | } |
315 | 315 | // edit attendee link |
316 | 316 | $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
317 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
317 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
318 | 318 | REG_ADMIN_URL |
319 | 319 | ); |
320 | 320 | $name_link = EE_Registry::instance()->CAP->current_user_can( |
321 | 321 | 'ee_edit_contacts', |
322 | 322 | 'espresso_registrations_edit_attendee' |
323 | 323 | ) |
324 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' |
|
324 | + ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact', 'event_espresso').'">' |
|
325 | 325 | . $item->attendee()->full_name() |
326 | 326 | . '</a>' |
327 | 327 | : $item->attendee()->full_name(); |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
330 | 330 | : ''; |
331 | 331 | //add group details |
332 | - $name_link .= ' ' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() ); |
|
332 | + $name_link .= ' '.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
333 | 333 | //add regcode |
334 | 334 | $link = EE_Admin_Page::add_query_args_and_nonce( |
335 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
335 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
336 | 336 | REG_ADMIN_URL |
337 | 337 | ); |
338 | 338 | $name_link .= '<br>'; |
@@ -341,37 +341,37 @@ discard block |
||
341 | 341 | 'view_registration', |
342 | 342 | $item->ID() |
343 | 343 | ) |
344 | - ? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
344 | + ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
345 | 345 | . $item->reg_code() |
346 | 346 | . '</a>' |
347 | 347 | : $item->reg_code(); |
348 | 348 | //status |
349 | 349 | $name_link .= '<br><span class="ee-status-text-small">'; |
350 | - $name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ); |
|
350 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
351 | 351 | $name_link .= '</span>'; |
352 | 352 | $actions = array(); |
353 | 353 | $DTT_ID = $this->_cur_dtt_id; |
354 | - $latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration |
|
354 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
355 | 355 | ? $item->get_latest_related_datetime() |
356 | 356 | : null; |
357 | 357 | $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
358 | 358 | ? $latest_related_datetime->ID() |
359 | 359 | : $DTT_ID; |
360 | - if ( ! empty( $DTT_ID ) |
|
360 | + if ( ! empty($DTT_ID) |
|
361 | 361 | && EE_Registry::instance()->CAP->current_user_can( |
362 | 362 | 'ee_read_checkins', |
363 | 363 | 'espresso_registrations_registration_checkins' |
364 | 364 | ) |
365 | 365 | ) { |
366 | 366 | $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
367 | - array( 'action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID ) |
|
367 | + array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID) |
|
368 | 368 | ); |
369 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__( |
|
369 | + $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__( |
|
370 | 370 | 'View all the check-ins/checkouts for this registrant', |
371 | 371 | 'event_espresso' |
372 | - ) . '">' . __( 'View', 'event_espresso' ) . '</a>'; |
|
372 | + ).'">'.__('View', 'event_espresso').'</a>'; |
|
373 | 373 | } |
374 | - return ! empty( $DTT_ID ) ? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions ) ) : $name_link; |
|
374 | + return ! empty($DTT_ID) ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)) : $name_link; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @param \EE_Registration $item |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public function column_ATT_email( EE_Registration $item ) { |
|
383 | + public function column_ATT_email(EE_Registration $item) { |
|
384 | 384 | $attendee = $item->attendee(); |
385 | 385 | return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
386 | 386 | } |
@@ -392,22 +392,22 @@ discard block |
||
392 | 392 | * @return bool|string |
393 | 393 | * @throws \EE_Error |
394 | 394 | */ |
395 | - public function column_Event( EE_Registration $item ) { |
|
395 | + public function column_Event(EE_Registration $item) { |
|
396 | 396 | try { |
397 | 397 | $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
398 | 398 | $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
399 | - array( 'action' => 'event_registrations', 'event_id' => $event->ID() ), |
|
399 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
400 | 400 | REG_ADMIN_URL |
401 | 401 | ); |
402 | 402 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
403 | 403 | 'ee_read_checkins', |
404 | 404 | 'espresso_registrations_registration_checkins' |
405 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__( |
|
405 | + ) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__( |
|
406 | 406 | 'View Checkins for this Event', |
407 | 407 | 'event_espresso' |
408 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
409 | - } catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) { |
|
410 | - $event_label = esc_html__( 'Unknown', 'event_espresso' ); |
|
408 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
409 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
410 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
411 | 411 | } |
412 | 412 | return $event_label; |
413 | 413 | } |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param \EE_Registration $item |
419 | 419 | * @return mixed|string|void |
420 | 420 | */ |
421 | - public function column_PRC_name( EE_Registration $item ) { |
|
422 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" ); |
|
421 | + public function column_PRC_name(EE_Registration $item) { |
|
422 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso"); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @param \EE_Registration $item |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - public function column__REG_final_price( EE_Registration $item ) { |
|
434 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
433 | + public function column__REG_final_price(EE_Registration $item) { |
|
434 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -443,13 +443,13 @@ discard block |
||
443 | 443 | * @return string |
444 | 444 | * @throws \EE_Error |
445 | 445 | */ |
446 | - public function column_TXN_paid( EE_Registration $item ) { |
|
447 | - if ( $item->count() === 1 ) { |
|
448 | - if ( $item->transaction()->paid() >= $item->transaction()->total() ) { |
|
446 | + public function column_TXN_paid(EE_Registration $item) { |
|
447 | + if ($item->count() === 1) { |
|
448 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
449 | 449 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
450 | 450 | } else { |
451 | 451 | $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
452 | - array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ), |
|
452 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
453 | 453 | TXN_ADMIN_URL |
454 | 454 | ); |
455 | 455 | return EE_Registry::instance()->CAP->current_user_can( |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | . '" href="' |
463 | 463 | . $view_txn_lnk_url |
464 | 464 | . '" title="' |
465 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
465 | + . esc_attr__('View Transaction', 'event_espresso') |
|
466 | 466 | . '"> |
467 | 467 | ' |
468 | 468 | . $item->transaction()->pretty_paid() |
469 | 469 | . ' |
470 | 470 | </a> |
471 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
471 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
472 | 472 | } |
473 | 473 | } else { |
474 | 474 | return '<span class="reg-pad-rght"></span>'; |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | * @return string |
485 | 485 | * @throws \EE_Error |
486 | 486 | */ |
487 | - public function column_TXN_total( EE_Registration $item ) { |
|
487 | + public function column_TXN_total(EE_Registration $item) { |
|
488 | 488 | $txn = $item->transaction(); |
489 | - $view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL ); |
|
490 | - if ( $item->get( 'REG_count' ) === 1 ) { |
|
489 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
490 | + if ($item->get('REG_count') === 1) { |
|
491 | 491 | $line_total_obj = $txn->total_line_item(); |
492 | 492 | $txn_total = $line_total_obj instanceof EE_Line_Item |
493 | - ? $line_total_obj->get_pretty( 'LIN_total' ) |
|
493 | + ? $line_total_obj->get_pretty('LIN_total') |
|
494 | 494 | : __( |
495 | 495 | 'View Transaction', |
496 | 496 | 'event_espresso' |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | ) ? '<a href="' |
502 | 502 | . $view_txn_url |
503 | 503 | . '" title="' |
504 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
504 | + . esc_attr__('View Transaction', 'event_espresso') |
|
505 | 505 | . '"><span class="reg-pad-rght">' |
506 | 506 | . $txn_total |
507 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
507 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
508 | 508 | } else { |
509 | 509 | return '<span class="reg-pad-rght"></span>'; |
510 | 510 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
186 | 186 | // first use WP locate_template to check for template in the current theme folder |
187 | - $template_path = locate_template( $templates ); |
|
187 | + $template_path = locate_template($templates); |
|
188 | 188 | |
189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
189 | + if ($check_if_custom && ! empty($template_path)) |
|
190 | 190 | return TRUE; |
191 | 191 | |
192 | 192 | // not in the theme |
193 | - if ( empty( $template_path )) { |
|
193 | + if (empty($template_path)) { |
|
194 | 194 | // not even a template to look for ? |
195 | - if ( empty( $templates )) { |
|
195 | + if (empty($templates)) { |
|
196 | 196 | // get post_type |
197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
198 | 198 | // get array of EE Custom Post Types |
199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
200 | 200 | // build template name based on request |
201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
201 | + if (isset($EE_CPTs[$post_type])) { |
|
202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | // currently active EE template theme |
@@ -210,81 +210,81 @@ discard block |
||
210 | 210 | // array of paths to folders that may contain templates |
211 | 211 | $template_folder_paths = array( |
212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
216 | 216 | ); |
217 | 217 | |
218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
219 | - if ( ! $check_if_custom ) { |
|
219 | + if ( ! $check_if_custom) { |
|
220 | 220 | $core_paths = array( |
221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
222 | - EE_PUBLIC . $current_theme, |
|
222 | + EE_PUBLIC.$current_theme, |
|
223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
224 | - EE_TEMPLATES . $current_theme, |
|
224 | + EE_TEMPLATES.$current_theme, |
|
225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
226 | 226 | EE_PLUGIN_DIR_PATH |
227 | 227 | ); |
228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // now filter that array |
232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
235 | 235 | // array to hold all possible template paths |
236 | 236 | $full_template_paths = array(); |
237 | 237 | |
238 | 238 | // loop through $templates |
239 | - foreach ( $templates as $template ) { |
|
239 | + foreach ($templates as $template) { |
|
240 | 240 | // normalize directory separators |
241 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
242 | - $file_name = basename( $template ); |
|
243 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
241 | + $template = EEH_File::standardise_directory_separators($template); |
|
242 | + $file_name = basename($template); |
|
243 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
244 | 244 | // while looping through all template folder paths |
245 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
245 | + foreach ($template_folder_paths as $template_folder_path) { |
|
246 | 246 | // normalize directory separators |
247 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
247 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
248 | 248 | // determine if any common base path exists between the two paths |
249 | 249 | $common_base_path = EEH_Template::_find_common_base_path( |
250 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
250 | + array($template_folder_path, $template_path_minus_file_name) |
|
251 | 251 | ); |
252 | - if ( $common_base_path !== '' ) { |
|
252 | + if ($common_base_path !== '') { |
|
253 | 253 | // both paths have a common base, so just tack the filename onto our search path |
254 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
254 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
255 | 255 | } else { |
256 | 256 | // no common base path, so let's just concatenate |
257 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
257 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
258 | 258 | } |
259 | 259 | // build up our template locations array by adding our resolved paths |
260 | 260 | $full_template_paths[] = $resolved_path; |
261 | 261 | } |
262 | 262 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
263 | - array_unshift( $full_template_paths, $template ); |
|
263 | + array_unshift($full_template_paths, $template); |
|
264 | 264 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
265 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
265 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
266 | 266 | } |
267 | 267 | // filter final array of full template paths |
268 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
268 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
269 | 269 | // now loop through our final array of template location paths and check each location |
270 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
271 | - if ( is_readable( $full_template_path )) { |
|
272 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
270 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
271 | + if (is_readable($full_template_path)) { |
|
272 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
273 | 273 | // hook that can be used to display the full template path that will be used |
274 | - do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path ); |
|
274 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | // if we got it and you want to see it... |
280 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
281 | - if ( $return_string ) { |
|
282 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
280 | + if ($template_path && $load && ! $check_if_custom) { |
|
281 | + if ($return_string) { |
|
282 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
283 | 283 | } else { |
284 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
284 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
285 | 285 | } |
286 | 286 | } |
287 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
287 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | * @param array $paths |
298 | 298 | * @return string |
299 | 299 | */ |
300 | - protected static function _find_common_base_path( $paths ) { |
|
300 | + protected static function _find_common_base_path($paths) { |
|
301 | 301 | $last_offset = 0; |
302 | 302 | $common_base_path = ''; |
303 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
303 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
304 | 304 | $dir_length = $index - $last_offset + 1; |
305 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
306 | - foreach ( $paths as $path ) { |
|
307 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
305 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
306 | + foreach ($paths as $path) { |
|
307 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
308 | 308 | return $common_base_path; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | $common_base_path .= $directory; |
312 | 312 | $last_offset = $index + 1; |
313 | 313 | } |
314 | - return substr( $common_base_path, 0, -1 ); |
|
314 | + return substr($common_base_path, 0, -1); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
324 | 324 | * @return mixed string |
325 | 325 | */ |
326 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
326 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -334,26 +334,26 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @since 4.6.0 |
336 | 336 | */ |
337 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
338 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
337 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
338 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
339 | 339 | |
340 | 340 | // you gimme nuttin - YOU GET NUTTIN !! |
341 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
341 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
342 | 342 | return ''; |
343 | 343 | } |
344 | 344 | // if $template_args are not in an array, then make it so |
345 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
346 | - $template_args = array( $template_args ); |
|
345 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
346 | + $template_args = array($template_args); |
|
347 | 347 | } |
348 | - extract( (array) $template_args); |
|
348 | + extract((array) $template_args); |
|
349 | 349 | |
350 | - if ( $return_string ) { |
|
350 | + if ($return_string) { |
|
351 | 351 | // because we want to return a string, we are going to capture the output |
352 | 352 | ob_start(); |
353 | - include( $template_path ); |
|
353 | + include($template_path); |
|
354 | 354 | return ob_get_clean(); |
355 | 355 | } else { |
356 | - include( $template_path ); |
|
356 | + include($template_path); |
|
357 | 357 | } |
358 | 358 | return ''; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * @param string $suffix added to the end of the generated class |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
374 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
375 | 375 | // in the beginning... |
376 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
376 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
377 | 377 | // da muddle |
378 | 378 | $class = ''; |
379 | 379 | // the end |
380 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
380 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
381 | 381 | // is the passed object an EE object ? |
382 | - if ( $object instanceof EE_Base_Class ) { |
|
382 | + if ($object instanceof EE_Base_Class) { |
|
383 | 383 | // grab the exact type of object |
384 | - $obj_class = get_class( $object ); |
|
384 | + $obj_class = get_class($object); |
|
385 | 385 | // depending on the type of object... |
386 | - switch ( $obj_class ) { |
|
386 | + switch ($obj_class) { |
|
387 | 387 | // no specifics just yet... |
388 | 388 | default : |
389 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
390 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
389 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
390 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | } |
394 | - return $prefix . $class . $suffix; |
|
394 | + return $prefix.$class.$suffix; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -407,54 +407,54 @@ discard block |
||
407 | 407 | * @param string $cur_code_span_class |
408 | 408 | * @return string the html output for the formatted money value |
409 | 409 | */ |
410 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
410 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
411 | 411 | // ensure amount was received |
412 | - if ( is_null( $amount ) ) { |
|
413 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
414 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
412 | + if (is_null($amount)) { |
|
413 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
414 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
415 | 415 | return ''; |
416 | 416 | } |
417 | 417 | //ensure amount is float |
418 | - $amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount ); |
|
419 | - $CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount ); |
|
418 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
419 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
422 | 422 | // still a number or was amount converted to a string like "free" ? |
423 | - if ( is_float( $amount_formatted )) { |
|
423 | + if (is_float($amount_formatted)) { |
|
424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
426 | 426 | // verify results |
427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
428 | 428 | // set default config country currency settings |
429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
430 | 430 | } |
431 | 431 | // format float |
432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
433 | 433 | // add formatting ? |
434 | - if ( ! $return_raw ) { |
|
434 | + if ( ! $return_raw) { |
|
435 | 435 | // add currency sign |
436 | - if( $mny->sign_b4 ){ |
|
437 | - if( $amount >= 0 ){ |
|
438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
439 | - }else{ |
|
440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
436 | + if ($mny->sign_b4) { |
|
437 | + if ($amount >= 0) { |
|
438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
439 | + } else { |
|
440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
441 | 441 | } |
442 | 442 | |
443 | - }else{ |
|
444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
443 | + } else { |
|
444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // filter to allow global setting of display_code |
448 | - $display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code ); |
|
448 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
449 | 449 | |
450 | 450 | // add currency code ? |
451 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
451 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
452 | 452 | } |
453 | 453 | // filter results |
454 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
454 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
455 | 455 | } |
456 | 456 | // clean up vars |
457 | - unset( $mny ); |
|
457 | + unset($mny); |
|
458 | 458 | // return formatted currency amount |
459 | 459 | return $amount_formatted; |
460 | 460 | } |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
470 | 470 | * @return string The localized label for the status id. |
471 | 471 | */ |
472 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
472 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
473 | 473 | /** @type EEM_Status $EEM_Status */ |
474 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
475 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
476 | - return $status[ $status_id ]; |
|
474 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
475 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
476 | + return $status[$status_id]; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -488,21 +488,21 @@ discard block |
||
488 | 488 | * @param string $title |
489 | 489 | * @return string the html output for the button |
490 | 490 | */ |
491 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '', $title = '' ) { |
|
491 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') { |
|
492 | 492 | $icon_html = ''; |
493 | - if ( ! empty( $icon ) ) { |
|
494 | - $dashicons = preg_split( "(ee-icon |dashicons )", $icon ); |
|
495 | - $dashicons = array_filter( $dashicons ); |
|
496 | - $count = count( $dashicons ); |
|
493 | + if ( ! empty($icon)) { |
|
494 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
495 | + $dashicons = array_filter($dashicons); |
|
496 | + $count = count($dashicons); |
|
497 | 497 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
498 | - foreach ( $dashicons as $dashicon ) { |
|
499 | - $type = strpos( $dashicon, 'ee-icon' ) !== false ? 'ee-icon ' : 'dashicons '; |
|
500 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
498 | + foreach ($dashicons as $dashicon) { |
|
499 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
500 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
501 | 501 | } |
502 | 502 | $icon_html .= $count > 1 ? '</span>' : ''; |
503 | 503 | } |
504 | - $label = ! empty( $icon ) ? $icon_html . $label : $label; |
|
505 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
504 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
505 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
506 | 506 | return $button; |
507 | 507 | } |
508 | 508 | |
@@ -519,21 +519,21 @@ discard block |
||
519 | 519 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
520 | 520 | * @return string generated link |
521 | 521 | */ |
522 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
522 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
523 | 523 | |
524 | - if ( ! $page ) |
|
525 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
524 | + if ( ! $page) |
|
525 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
526 | 526 | |
527 | - if ( ! $action ) |
|
528 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
527 | + if ( ! $action) |
|
528 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
529 | 529 | |
530 | 530 | $action = empty($action) ? 'default' : $action; |
531 | 531 | |
532 | 532 | |
533 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
534 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
535 | - $help_text = !$help_text ? '' : $help_text; |
|
536 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
533 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
534 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
535 | + $help_text = ! $help_text ? '' : $help_text; |
|
536 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,31 +545,31 @@ discard block |
||
545 | 545 | * @param EE_Help_Tour |
546 | 546 | * @return string html |
547 | 547 | */ |
548 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
548 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
549 | 549 | $id = $tour->get_slug(); |
550 | 550 | $stops = $tour->get_stops(); |
551 | 551 | |
552 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
552 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
553 | 553 | |
554 | - foreach ( $stops as $stop ) { |
|
555 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
556 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
554 | + foreach ($stops as $stop) { |
|
555 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
556 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
557 | 557 | |
558 | 558 | //if container is set to modal then let's make sure we set the options accordingly |
559 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
559 | + if (empty($data_id) && empty($data_class)) { |
|
560 | 560 | $stop['options']['modal'] = true; |
561 | 561 | $stop['options']['expose'] = true; |
562 | 562 | } |
563 | 563 | |
564 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
565 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
564 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
565 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
566 | 566 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
567 | 567 | |
568 | 568 | //options |
569 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
569 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
570 | 570 | $options = ' data-options="'; |
571 | - foreach ( $stop['options'] as $option => $value ) { |
|
572 | - $options .= $option . ':' . $value . ';'; |
|
571 | + foreach ($stop['options'] as $option => $value) { |
|
572 | + $options .= $option.':'.$value.';'; |
|
573 | 573 | } |
574 | 574 | $options .= '"'; |
575 | 575 | } else { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | //let's put all together |
580 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
580 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | $content .= '</ol>'; |
@@ -598,31 +598,31 @@ discard block |
||
598 | 598 | * @throws EE_Error |
599 | 599 | * @return string html structure for status. |
600 | 600 | */ |
601 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
602 | - if ( !is_array( $status_array ) ) |
|
603 | - throw new EE_Error( esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
601 | + public static function status_legend($status_array, $active_status = '') { |
|
602 | + if ( ! is_array($status_array)) |
|
603 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
604 | 604 | |
605 | 605 | $setup_array = array(); |
606 | - foreach ( $status_array as $item => $status ) { |
|
606 | + foreach ($status_array as $item => $status) { |
|
607 | 607 | $setup_array[$item] = array( |
608 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
609 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
608 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
609 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
610 | 610 | 'status' => $status |
611 | 611 | ); |
612 | 612 | } |
613 | 613 | |
614 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
615 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
616 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
617 | - foreach ( $setup_array as $item => $details ) { |
|
614 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
615 | + $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
616 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
617 | + foreach ($setup_array as $item => $details) { |
|
618 | 618 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
619 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
620 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
621 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
622 | - $content .= '</dt>' . "\n"; |
|
619 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
620 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
621 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
622 | + $content .= '</dt>'."\n"; |
|
623 | 623 | } |
624 | - $content .= '</dl>' . "\n"; |
|
625 | - $content .= '</div>' . "\n"; |
|
624 | + $content .= '</dl>'."\n"; |
|
625 | + $content .= '</div>'."\n"; |
|
626 | 626 | return $content; |
627 | 627 | } |
628 | 628 | |
@@ -635,8 +635,8 @@ discard block |
||
635 | 635 | * @return string |
636 | 636 | */ |
637 | 637 | public static function layout_array_as_table($data) { |
638 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
639 | - $data = (array)$data; |
|
638 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
639 | + $data = (array) $data; |
|
640 | 640 | } |
641 | 641 | ob_start(); |
642 | 642 | if (is_array($data)) { |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | ?> |
650 | 650 | <tr> |
651 | 651 | <td> |
652 | - <?php echo $data_key;?> |
|
652 | + <?php echo $data_key; ?> |
|
653 | 653 | </td> |
654 | 654 | <td> |
655 | - <?php echo self::layout_array_as_table($data_values);?> |
|
655 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
656 | 656 | </td> |
657 | 657 | </tr> |
658 | 658 | <?php |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | <ul> |
667 | 667 | <?php |
668 | 668 | foreach ($data as $datum) { |
669 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
669 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
670 | 670 | }?> |
671 | 671 | </ul> |
672 | 672 | <?php |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
700 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
699 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
700 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | * ) |
722 | 722 | * @return string |
723 | 723 | */ |
724 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
724 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
725 | 725 | $page_links = array(); |
726 | 726 | $disable_first = $disable_last = ''; |
727 | 727 | $total_items = (int) $total_items; |
728 | 728 | $per_page = (int) $per_page; |
729 | 729 | $current = (int) $current; |
730 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
730 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
731 | 731 | |
732 | 732 | //filter items_label |
733 | 733 | $items_label = apply_filters( |
@@ -735,68 +735,68 @@ discard block |
||
735 | 735 | $items_label |
736 | 736 | ); |
737 | 737 | |
738 | - if ( empty( $items_label ) |
|
739 | - || ! is_array( $items_label ) |
|
740 | - || ! isset( $items_label['single'] ) |
|
741 | - || ! isset( $items_label['plural'] ) ) { |
|
738 | + if (empty($items_label) |
|
739 | + || ! is_array($items_label) |
|
740 | + || ! isset($items_label['single']) |
|
741 | + || ! isset($items_label['plural'])) { |
|
742 | 742 | $items_label = array( |
743 | - 'single' => __( '1 item', 'event_espresso' ), |
|
744 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
743 | + 'single' => __('1 item', 'event_espresso'), |
|
744 | + 'plural' => __('%s items', 'event_espresso') |
|
745 | 745 | ); |
746 | 746 | } else { |
747 | 747 | $items_label = array( |
748 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
749 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
748 | + 'single' => '1 '.esc_html($items_label['single']), |
|
749 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
750 | 750 | ); |
751 | 751 | } |
752 | 752 | |
753 | - $total_pages = ceil( $total_items / $per_page ); |
|
753 | + $total_pages = ceil($total_items / $per_page); |
|
754 | 754 | |
755 | - if ( $total_pages <= 1 ) |
|
755 | + if ($total_pages <= 1) |
|
756 | 756 | return ''; |
757 | 757 | |
758 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
758 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
759 | 759 | |
760 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
760 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
761 | 761 | |
762 | - if ( $current === 1 ) { |
|
762 | + if ($current === 1) { |
|
763 | 763 | $disable_first = ' disabled'; |
764 | 764 | } |
765 | - if ( $current == $total_pages ) { |
|
765 | + if ($current == $total_pages) { |
|
766 | 766 | $disable_last = ' disabled'; |
767 | 767 | } |
768 | 768 | |
769 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
770 | - 'first-page' . $disable_first, |
|
771 | - esc_attr__( 'Go to the first page' ), |
|
772 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
769 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
770 | + 'first-page'.$disable_first, |
|
771 | + esc_attr__('Go to the first page'), |
|
772 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
773 | 773 | '«' |
774 | 774 | ); |
775 | 775 | |
776 | 776 | $page_links[] = sprintf( |
777 | 777 | '<a class="%s" title="%s" href="%s">%s</a>', |
778 | - 'prev-page' . $disable_first, |
|
779 | - esc_attr__( 'Go to the previous page' ), |
|
780 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
778 | + 'prev-page'.$disable_first, |
|
779 | + esc_attr__('Go to the previous page'), |
|
780 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
781 | 781 | '‹' |
782 | 782 | ); |
783 | 783 | |
784 | - if ( ! $show_num_field ) { |
|
784 | + if ( ! $show_num_field) { |
|
785 | 785 | $html_current_page = $current; |
786 | 786 | } else { |
787 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
788 | - esc_attr__( 'Current page' ), |
|
787 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
788 | + esc_attr__('Current page'), |
|
789 | 789 | $current, |
790 | - strlen( $total_pages ) |
|
790 | + strlen($total_pages) |
|
791 | 791 | ); |
792 | 792 | } |
793 | 793 | |
794 | 794 | $html_total_pages = sprintf( |
795 | 795 | '<span class="total-pages">%s</span>', |
796 | - number_format_i18n( $total_pages ) |
|
796 | + number_format_i18n($total_pages) |
|
797 | 797 | ); |
798 | 798 | $page_links[] = sprintf( |
799 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
799 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
800 | 800 | $html_current_page, |
801 | 801 | $html_total_pages, |
802 | 802 | '<span class="paging-input">', |
@@ -805,29 +805,29 @@ discard block |
||
805 | 805 | |
806 | 806 | $page_links[] = sprintf( |
807 | 807 | '<a class="%s" title="%s" href="%s">%s</a>', |
808 | - 'next-page' . $disable_last, |
|
809 | - esc_attr__( 'Go to the next page' ), |
|
810 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
808 | + 'next-page'.$disable_last, |
|
809 | + esc_attr__('Go to the next page'), |
|
810 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
811 | 811 | '›' |
812 | 812 | ); |
813 | 813 | |
814 | 814 | $page_links[] = sprintf( |
815 | 815 | '<a class="%s" title="%s" href="%s">%s</a>', |
816 | - 'last-page' . $disable_last, |
|
817 | - esc_attr__( 'Go to the last page' ), |
|
818 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
816 | + 'last-page'.$disable_last, |
|
817 | + esc_attr__('Go to the last page'), |
|
818 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
819 | 819 | '»' |
820 | 820 | ); |
821 | 821 | |
822 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
822 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
823 | 823 | // set page class |
824 | - if ( $total_pages ) { |
|
824 | + if ($total_pages) { |
|
825 | 825 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
826 | 826 | } else { |
827 | 827 | $page_class = ' no-pages'; |
828 | 828 | } |
829 | 829 | |
830 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
830 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * @param string $wrap_id |
838 | 838 | * @return string |
839 | 839 | */ |
840 | - public static function powered_by_event_espresso( $wrap_class = '', $wrap_id = '', array $query_args = array() ) { |
|
841 | - $admin = is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
840 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) { |
|
841 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
842 | 842 | if ( |
843 | 843 | ! $admin && |
844 | 844 | ! apply_filters( |
@@ -849,9 +849,9 @@ discard block |
||
849 | 849 | return ''; |
850 | 850 | } |
851 | 851 | $tag = $admin ? 'span' : 'div'; |
852 | - $attributes = ! empty( $wrap_id ) ? " id=\"{$wrap_id}\"" : ''; |
|
852 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
853 | 853 | $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
854 | - $attributes .= ! empty( $wrap_class ) |
|
854 | + $attributes .= ! empty($wrap_class) |
|
855 | 855 | ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
856 | 856 | : ' class="powered-by-event-espresso-credit"'; |
857 | 857 | $query_args = array_merge( |
@@ -863,9 +863,9 @@ discard block |
||
863 | 863 | ), |
864 | 864 | $query_args |
865 | 865 | ); |
866 | - $powered_by = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso_text', $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso' ); |
|
867 | - $url = add_query_arg( $query_args, 'https://eventespresso.com/' ); |
|
868 | - $url = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso__url', $url ); |
|
866 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
867 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
868 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
869 | 869 | return (string) apply_filters( |
870 | 870 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
871 | 871 | sprintf( |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
898 | 898 | |
899 | 899 | |
900 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
900 | +if ( ! function_exists('espresso_pagination')) { |
|
901 | 901 | /** |
902 | 902 | * espresso_pagination |
903 | 903 | * |
@@ -909,21 +909,21 @@ discard block |
||
909 | 909 | $big = 999999999; // need an unlikely integer |
910 | 910 | $pagination = paginate_links( |
911 | 911 | array( |
912 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
912 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
913 | 913 | 'format' => '?paged=%#%', |
914 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
914 | + 'current' => max(1, get_query_var('paged')), |
|
915 | 915 | 'total' => $wp_query->max_num_pages, |
916 | 916 | 'show_all' => true, |
917 | 917 | 'end_size' => 10, |
918 | 918 | 'mid_size' => 6, |
919 | 919 | 'prev_next' => true, |
920 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
921 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
920 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
921 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
922 | 922 | 'type' => 'plain', |
923 | 923 | 'add_args' => false, |
924 | 924 | 'add_fragment' => '' |
925 | 925 | ) |
926 | 926 | ); |
927 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
927 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | \ No newline at end of file |
@@ -186,8 +186,9 @@ discard block |
||
186 | 186 | // first use WP locate_template to check for template in the current theme folder |
187 | 187 | $template_path = locate_template( $templates ); |
188 | 188 | |
189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
190 | - return TRUE; |
|
189 | + if ( $check_if_custom && !empty( $template_path ) ) { |
|
190 | + return TRUE; |
|
191 | + } |
|
191 | 192 | |
192 | 193 | // not in the theme |
193 | 194 | if ( empty( $template_path )) { |
@@ -436,11 +437,11 @@ discard block |
||
436 | 437 | if( $mny->sign_b4 ){ |
437 | 438 | if( $amount >= 0 ){ |
438 | 439 | $amount_formatted = $mny->sign . $amount_formatted; |
439 | - }else{ |
|
440 | + } else{ |
|
440 | 441 | $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
441 | 442 | } |
442 | 443 | |
443 | - }else{ |
|
444 | + } else{ |
|
444 | 445 | $amount_formatted = $amount_formatted . $mny->sign; |
445 | 446 | } |
446 | 447 | |
@@ -521,11 +522,13 @@ discard block |
||
521 | 522 | */ |
522 | 523 | public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
523 | 524 | |
524 | - if ( ! $page ) |
|
525 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
525 | + if ( ! $page ) { |
|
526 | + $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
527 | + } |
|
526 | 528 | |
527 | - if ( ! $action ) |
|
528 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
529 | + if ( ! $action ) { |
|
530 | + $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
531 | + } |
|
529 | 532 | |
530 | 533 | $action = empty($action) ? 'default' : $action; |
531 | 534 | |
@@ -599,8 +602,9 @@ discard block |
||
599 | 602 | * @return string html structure for status. |
600 | 603 | */ |
601 | 604 | public static function status_legend( $status_array, $active_status = '' ) { |
602 | - if ( !is_array( $status_array ) ) |
|
603 | - throw new EE_Error( esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
605 | + if ( !is_array( $status_array ) ) { |
|
606 | + throw new EE_Error( esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
607 | + } |
|
604 | 608 | |
605 | 609 | $setup_array = array(); |
606 | 610 | foreach ( $status_array as $item => $status ) { |
@@ -660,8 +664,7 @@ discard block |
||
660 | 664 | </tbody> |
661 | 665 | </table> |
662 | 666 | <?php |
663 | - } |
|
664 | - else { |
|
667 | + } else { |
|
665 | 668 | ?> |
666 | 669 | <ul> |
667 | 670 | <?php |
@@ -671,8 +674,7 @@ discard block |
||
671 | 674 | </ul> |
672 | 675 | <?php |
673 | 676 | } |
674 | - } |
|
675 | - else { |
|
677 | + } else { |
|
676 | 678 | //simple value |
677 | 679 | echo $data; |
678 | 680 | } |
@@ -752,8 +754,9 @@ discard block |
||
752 | 754 | |
753 | 755 | $total_pages = ceil( $total_items / $per_page ); |
754 | 756 | |
755 | - if ( $total_pages <= 1 ) |
|
756 | - return ''; |
|
757 | + if ( $total_pages <= 1 ) { |
|
758 | + return ''; |
|
759 | + } |
|
757 | 760 | |
758 | 761 | $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
759 | 762 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * @param bool $routing |
43 | 43 | * @return \Extend_Transactions_Admin_Page |
44 | 44 | */ |
45 | - public function __construct( $routing = TRUE ) { |
|
46 | - parent::__construct( $routing ); |
|
47 | - define( 'TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
48 | - define( 'TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
49 | - define( 'TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
45 | + public function __construct($routing = TRUE) { |
|
46 | + parent::__construct($routing); |
|
47 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/'); |
|
48 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/'); |
|
49 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @return void |
59 | 59 | */ |
60 | 60 | protected function _extend_page_config() { |
61 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
61 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions'; |
|
62 | 62 | |
63 | 63 | $new_page_routes = array( |
64 | 64 | 'reports' => array( |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ) |
68 | 68 | ); |
69 | 69 | |
70 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
70 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
71 | 71 | |
72 | 72 | $new_page_config = array( |
73 | 73 | 'reports' => array( |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | 'require_nonce' => FALSE |
86 | 86 | ) |
87 | 87 | ); |
88 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
88 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @return void |
98 | 98 | */ |
99 | 99 | public function load_scripts_styles_reports() { |
100 | - wp_register_script( 'ee-txn-reports-js', TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', array( 'google-charts' ), EVENT_ESPRESSO_VERSION, true ); |
|
101 | - wp_enqueue_script( 'ee-txn-reports-js' ); |
|
100 | + wp_register_script('ee-txn-reports-js', TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js', array('google-charts'), EVENT_ESPRESSO_VERSION, true); |
|
101 | + wp_enqueue_script('ee-txn-reports-js'); |
|
102 | 102 | $this->_transaction_reports_js_setup(); |
103 | 103 | EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
104 | 104 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | protected function _transaction_reports() { |
128 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
128 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
129 | 129 | $this->_admin_page_title = __('Transactions', 'event_espresso'); |
130 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_reports_template_data, TRUE ); |
|
130 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_reports_template_data, TRUE); |
|
131 | 131 | |
132 | 132 | // the final template wrapper |
133 | 133 | $this->display_admin_page_with_no_sidebar(); |
@@ -142,40 +142,40 @@ discard block |
||
142 | 142 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - private function _revenue_per_day_report( $period = '-1 month' ) { |
|
145 | + private function _revenue_per_day_report($period = '-1 month') { |
|
146 | 146 | |
147 | 147 | $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
148 | 148 | |
149 | 149 | $TXN = EEM_Transaction::instance(); |
150 | 150 | |
151 | - $results = $TXN->get_revenue_per_day_report( $period ); |
|
151 | + $results = $TXN->get_revenue_per_day_report($period); |
|
152 | 152 | $results = (array) $results; |
153 | 153 | $revenue = array(); |
154 | 154 | $subtitle = ''; |
155 | 155 | |
156 | - if ( $results ) { |
|
157 | - $revenue[] = array( __( 'Date (only shows dates that have a revenue greater than 1)', 'event_espresso' ), __( 'Total Revenue', 'event_espresso' ) ); |
|
158 | - foreach ( $results as $result ) { |
|
159 | - $revenue[] = array( $result->txnDate, (float) $result->revenue ); |
|
156 | + if ($results) { |
|
157 | + $revenue[] = array(__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), __('Total Revenue', 'event_espresso')); |
|
158 | + foreach ($results as $result) { |
|
159 | + $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | //setup the date range. |
163 | - $beginning_date = new DateTime( 'now' . $period, new DateTimeZone( EEH_DTT_Helper::get_timezone() ) ); |
|
164 | - $ending_date = new DateTime( 'now', new DateTimeZone( EEH_DTT_Helper::get_timezone() ) ); |
|
165 | - $subtitle = sprintf( _x( 'For the period: %s to %s', 'Used to give date range', 'event_espresso' ), $beginning_date->format( 'Y-m-d' ), $ending_date->format( 'Y-m-d' ) ); |
|
163 | + $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
164 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
165 | + $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
166 | 166 | } |
167 | 167 | |
168 | - $report_title = esc_html__( 'Total Revenue per Day', 'event_espresso' ); |
|
168 | + $report_title = esc_html__('Total Revenue per Day', 'event_espresso'); |
|
169 | 169 | |
170 | 170 | $report_params = array( |
171 | 171 | 'title' => $report_title, |
172 | 172 | 'subtitle' => $subtitle, |
173 | 173 | 'id' => $report_ID, |
174 | 174 | 'revenue' => $revenue, |
175 | - 'noResults' => empty( $revenue ) || count( $revenue ) === 1, |
|
176 | - 'noTxnMsg' => sprintf( __( '%sThere is no revenue to report for the last 30 days.%s', 'event_espresso' ), '<h2>' . $report_title . '</h2><p>', '</p>' ) |
|
175 | + 'noResults' => empty($revenue) || count($revenue) === 1, |
|
176 | + 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), '<h2>'.$report_title.'</h2><p>', '</p>') |
|
177 | 177 | ); |
178 | - wp_localize_script( 'ee-txn-reports-js', 'txnRevPerDay', $report_params ); |
|
178 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
179 | 179 | |
180 | 180 | return $report_ID; |
181 | 181 | } |
@@ -189,43 +189,43 @@ discard block |
||
189 | 189 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
190 | 190 | * @return int |
191 | 191 | */ |
192 | - private function _revenue_per_event_report( $period = '-1 month' ) { |
|
192 | + private function _revenue_per_event_report($period = '-1 month') { |
|
193 | 193 | |
194 | 194 | $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
195 | 195 | |
196 | 196 | $TXN = EEM_Transaction::instance(); |
197 | - $results = $TXN->get_revenue_per_event_report( $period ); |
|
197 | + $results = $TXN->get_revenue_per_event_report($period); |
|
198 | 198 | $results = (array) $results; |
199 | 199 | $revenue = array(); |
200 | 200 | $subtitle = ''; |
201 | 201 | |
202 | - if ( $results ) { |
|
203 | - $revenue[] = array( __( 'Event (only events that have a revenue greater than 1 are shown)', 'event_espresso' ), __( 'Total Revenue', 'event_espresso' ) ); |
|
204 | - foreach ( $results as $result ) { |
|
205 | - if ( $result->revenue > 1 ) { |
|
206 | - $event_name = stripslashes( html_entity_decode( $result->event_name, ENT_QUOTES, 'UTF-8' ) ); |
|
207 | - $event_name = wp_trim_words( $event_name, 5, '...' ); |
|
208 | - $revenue[] = array( $event_name, (float) $result->revenue ); |
|
202 | + if ($results) { |
|
203 | + $revenue[] = array(__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), __('Total Revenue', 'event_espresso')); |
|
204 | + foreach ($results as $result) { |
|
205 | + if ($result->revenue > 1) { |
|
206 | + $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
207 | + $event_name = wp_trim_words($event_name, 5, '...'); |
|
208 | + $revenue[] = array($event_name, (float) $result->revenue); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | 212 | //setup the date range. |
213 | - $beginning_date = new DateTime( 'now' . $period, new DateTimeZone( EEH_DTT_Helper::get_timezone() ) ); |
|
214 | - $ending_date = new DateTime( 'now', new DateTimeZone( EEH_DTT_Helper::get_timezone() ) ); |
|
215 | - $subtitle = sprintf( _x( 'For the period: %s to %s', 'Used to give date range', 'event_espresso' ), $beginning_date->format( 'Y-m-d' ), $ending_date->format( 'Y-m-d' ) ); |
|
213 | + $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
214 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
215 | + $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
216 | 216 | } |
217 | 217 | |
218 | - $report_title = esc_html__( 'Total Revenue per Event', 'event_espresso' ); |
|
218 | + $report_title = esc_html__('Total Revenue per Event', 'event_espresso'); |
|
219 | 219 | |
220 | 220 | $report_params = array( |
221 | 221 | 'title' => $report_title, |
222 | 222 | 'subtitle' => $subtitle, |
223 | 223 | 'id' => $report_ID, |
224 | 224 | 'revenue' => $revenue, |
225 | - 'noResults' => empty( $revenue ), |
|
226 | - 'noTxnMsg' => sprintf( __( '%sThere is no revenue to report for the last 30 days.%s', 'event_espresso' ), '<h2>' . $report_title . '</h2><p>', '</p>' ) |
|
225 | + 'noResults' => empty($revenue), |
|
226 | + 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), '<h2>'.$report_title.'</h2><p>', '</p>') |
|
227 | 227 | ); |
228 | - wp_localize_script( 'ee-txn-reports-js', 'txnRevPerEvent', $report_params ); |
|
228 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
229 | 229 | |
230 | 230 | return $report_ID; |
231 | 231 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | /** |
580 | 580 | * returns any events attached to this attendee ($_Event property); |
581 | 581 | * |
582 | - * @return array |
|
582 | + * @return EE_Base_Class[] |
|
583 | 583 | */ |
584 | 584 | public function events() |
585 | 585 | { |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * used to save the billing info |
595 | 595 | * |
596 | 596 | * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
597 | - * @return EE_Form_Section_Proper|null |
|
597 | + * @return null|EE_Billing_Info_Form |
|
598 | 598 | */ |
599 | 599 | public function billing_info_for_payment_method($payment_method) |
600 | 600 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -23,676 +23,676 @@ discard block |
||
23 | 23 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * Sets some dynamic defaults |
|
28 | - * |
|
29 | - * @param array $fieldValues |
|
30 | - * @param bool $bydb |
|
31 | - * @param string $timezone |
|
32 | - * @param array $date_formats |
|
33 | - */ |
|
34 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
35 | - { |
|
36 | - if ( ! isset($fieldValues['ATT_full_name'])) { |
|
37 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
38 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
39 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
40 | - } |
|
41 | - if ( ! isset($fieldValues['ATT_slug'])) { |
|
42 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
43 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
44 | - } |
|
45 | - if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
46 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
47 | - } |
|
48 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @param array $props_n_values incoming values |
|
54 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
55 | - * used.) |
|
56 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
57 | - * date_format and the second value is the time format |
|
58 | - * |
|
59 | - * @return EE_Attendee |
|
60 | - */ |
|
61 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
62 | - { |
|
63 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | + /** |
|
27 | + * Sets some dynamic defaults |
|
28 | + * |
|
29 | + * @param array $fieldValues |
|
30 | + * @param bool $bydb |
|
31 | + * @param string $timezone |
|
32 | + * @param array $date_formats |
|
33 | + */ |
|
34 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
35 | + { |
|
36 | + if ( ! isset($fieldValues['ATT_full_name'])) { |
|
37 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
38 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
39 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
40 | + } |
|
41 | + if ( ! isset($fieldValues['ATT_slug'])) { |
|
42 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
43 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
44 | + } |
|
45 | + if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
46 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
47 | + } |
|
48 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @param array $props_n_values incoming values |
|
54 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
55 | + * used.) |
|
56 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
57 | + * date_format and the second value is the time format |
|
58 | + * |
|
59 | + * @return EE_Attendee |
|
60 | + */ |
|
61 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
62 | + { |
|
63 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
64 | 64 | |
65 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @param array $props_n_values incoming values from the database |
|
71 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
72 | - * the website will be used. |
|
73 | - * |
|
74 | - * @return EE_Attendee |
|
75 | - */ |
|
76 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
77 | - { |
|
78 | - return new self($props_n_values, true, $timezone); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Set Attendee First Name |
|
84 | - * |
|
85 | - * @access public |
|
86 | - * |
|
87 | - * @param string $fname |
|
88 | - */ |
|
89 | - public function set_fname($fname = '') |
|
90 | - { |
|
91 | - $this->set('ATT_fname', $fname); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Set Attendee Last Name |
|
97 | - * |
|
98 | - * @access public |
|
99 | - * |
|
100 | - * @param string $lname |
|
101 | - */ |
|
102 | - public function set_lname($lname = '') |
|
103 | - { |
|
104 | - $this->set('ATT_lname', $lname); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * Set Attendee Address |
|
110 | - * |
|
111 | - * @access public |
|
112 | - * |
|
113 | - * @param string $address |
|
114 | - */ |
|
115 | - public function set_address($address = '') |
|
116 | - { |
|
117 | - $this->set('ATT_address', $address); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * Set Attendee Address2 |
|
123 | - * |
|
124 | - * @access public |
|
125 | - * |
|
126 | - * @param string $address2 |
|
127 | - */ |
|
128 | - public function set_address2($address2 = '') |
|
129 | - { |
|
130 | - $this->set('ATT_address2', $address2); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * Set Attendee City |
|
136 | - * |
|
137 | - * @access public |
|
138 | - * |
|
139 | - * @param string $city |
|
140 | - */ |
|
141 | - public function set_city($city = '') |
|
142 | - { |
|
143 | - $this->set('ATT_city', $city); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * Set Attendee State ID |
|
149 | - * |
|
150 | - * @access public |
|
151 | - * |
|
152 | - * @param int $STA_ID |
|
153 | - */ |
|
154 | - public function set_state($STA_ID = 0) |
|
155 | - { |
|
156 | - $this->set('STA_ID', $STA_ID); |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * Set Attendee Country ISO Code |
|
162 | - * |
|
163 | - * @access public |
|
164 | - * |
|
165 | - * @param string $CNT_ISO |
|
166 | - */ |
|
167 | - public function set_country($CNT_ISO = '') |
|
168 | - { |
|
169 | - $this->set('CNT_ISO', $CNT_ISO); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * Set Attendee Zip/Postal Code |
|
175 | - * |
|
176 | - * @access public |
|
177 | - * |
|
178 | - * @param string $zip |
|
179 | - */ |
|
180 | - public function set_zip($zip = '') |
|
181 | - { |
|
182 | - $this->set('ATT_zip', $zip); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Set Attendee Email Address |
|
188 | - * |
|
189 | - * @access public |
|
190 | - * |
|
191 | - * @param string $email |
|
192 | - */ |
|
193 | - public function set_email($email = '') |
|
194 | - { |
|
195 | - $this->set('ATT_email', $email); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Set Attendee Phone |
|
201 | - * |
|
202 | - * @access public |
|
203 | - * |
|
204 | - * @param string $phone |
|
205 | - */ |
|
206 | - public function set_phone($phone = '') |
|
207 | - { |
|
208 | - $this->set('ATT_phone', $phone); |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * set deleted |
|
214 | - * |
|
215 | - * @access public |
|
216 | - * |
|
217 | - * @param bool $ATT_deleted |
|
218 | - */ |
|
219 | - public function set_deleted($ATT_deleted = false) |
|
220 | - { |
|
221 | - $this->set('ATT_deleted', $ATT_deleted); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * Returns the value for the post_author id saved with the cpt |
|
227 | - * |
|
228 | - * @since 4.5.0 |
|
229 | - * @return int |
|
230 | - */ |
|
231 | - public function wp_user() |
|
232 | - { |
|
233 | - return $this->get('ATT_author'); |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * get Attendee First Name |
|
239 | - * |
|
240 | - * @access public |
|
241 | - * @return string |
|
242 | - */ |
|
243 | - public function fname() |
|
244 | - { |
|
245 | - return $this->get('ATT_fname'); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * echoes out the attendee's first name |
|
251 | - * |
|
252 | - * @return void |
|
253 | - */ |
|
254 | - public function e_full_name() |
|
255 | - { |
|
256 | - echo $this->full_name(); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * Returns the first and last name concatenated together with a space. |
|
262 | - * |
|
263 | - * @param bool $apply_html_entities |
|
264 | - * |
|
265 | - * @return string |
|
266 | - */ |
|
267 | - public function full_name($apply_html_entities = false) |
|
268 | - { |
|
269 | - $full_name = $this->fname() . ' ' . $this->lname(); |
|
65 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @param array $props_n_values incoming values from the database |
|
71 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
72 | + * the website will be used. |
|
73 | + * |
|
74 | + * @return EE_Attendee |
|
75 | + */ |
|
76 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
77 | + { |
|
78 | + return new self($props_n_values, true, $timezone); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Set Attendee First Name |
|
84 | + * |
|
85 | + * @access public |
|
86 | + * |
|
87 | + * @param string $fname |
|
88 | + */ |
|
89 | + public function set_fname($fname = '') |
|
90 | + { |
|
91 | + $this->set('ATT_fname', $fname); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Set Attendee Last Name |
|
97 | + * |
|
98 | + * @access public |
|
99 | + * |
|
100 | + * @param string $lname |
|
101 | + */ |
|
102 | + public function set_lname($lname = '') |
|
103 | + { |
|
104 | + $this->set('ATT_lname', $lname); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * Set Attendee Address |
|
110 | + * |
|
111 | + * @access public |
|
112 | + * |
|
113 | + * @param string $address |
|
114 | + */ |
|
115 | + public function set_address($address = '') |
|
116 | + { |
|
117 | + $this->set('ATT_address', $address); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * Set Attendee Address2 |
|
123 | + * |
|
124 | + * @access public |
|
125 | + * |
|
126 | + * @param string $address2 |
|
127 | + */ |
|
128 | + public function set_address2($address2 = '') |
|
129 | + { |
|
130 | + $this->set('ATT_address2', $address2); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * Set Attendee City |
|
136 | + * |
|
137 | + * @access public |
|
138 | + * |
|
139 | + * @param string $city |
|
140 | + */ |
|
141 | + public function set_city($city = '') |
|
142 | + { |
|
143 | + $this->set('ATT_city', $city); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * Set Attendee State ID |
|
149 | + * |
|
150 | + * @access public |
|
151 | + * |
|
152 | + * @param int $STA_ID |
|
153 | + */ |
|
154 | + public function set_state($STA_ID = 0) |
|
155 | + { |
|
156 | + $this->set('STA_ID', $STA_ID); |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * Set Attendee Country ISO Code |
|
162 | + * |
|
163 | + * @access public |
|
164 | + * |
|
165 | + * @param string $CNT_ISO |
|
166 | + */ |
|
167 | + public function set_country($CNT_ISO = '') |
|
168 | + { |
|
169 | + $this->set('CNT_ISO', $CNT_ISO); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * Set Attendee Zip/Postal Code |
|
175 | + * |
|
176 | + * @access public |
|
177 | + * |
|
178 | + * @param string $zip |
|
179 | + */ |
|
180 | + public function set_zip($zip = '') |
|
181 | + { |
|
182 | + $this->set('ATT_zip', $zip); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Set Attendee Email Address |
|
188 | + * |
|
189 | + * @access public |
|
190 | + * |
|
191 | + * @param string $email |
|
192 | + */ |
|
193 | + public function set_email($email = '') |
|
194 | + { |
|
195 | + $this->set('ATT_email', $email); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Set Attendee Phone |
|
201 | + * |
|
202 | + * @access public |
|
203 | + * |
|
204 | + * @param string $phone |
|
205 | + */ |
|
206 | + public function set_phone($phone = '') |
|
207 | + { |
|
208 | + $this->set('ATT_phone', $phone); |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * set deleted |
|
214 | + * |
|
215 | + * @access public |
|
216 | + * |
|
217 | + * @param bool $ATT_deleted |
|
218 | + */ |
|
219 | + public function set_deleted($ATT_deleted = false) |
|
220 | + { |
|
221 | + $this->set('ATT_deleted', $ATT_deleted); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * Returns the value for the post_author id saved with the cpt |
|
227 | + * |
|
228 | + * @since 4.5.0 |
|
229 | + * @return int |
|
230 | + */ |
|
231 | + public function wp_user() |
|
232 | + { |
|
233 | + return $this->get('ATT_author'); |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * get Attendee First Name |
|
239 | + * |
|
240 | + * @access public |
|
241 | + * @return string |
|
242 | + */ |
|
243 | + public function fname() |
|
244 | + { |
|
245 | + return $this->get('ATT_fname'); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * echoes out the attendee's first name |
|
251 | + * |
|
252 | + * @return void |
|
253 | + */ |
|
254 | + public function e_full_name() |
|
255 | + { |
|
256 | + echo $this->full_name(); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * Returns the first and last name concatenated together with a space. |
|
262 | + * |
|
263 | + * @param bool $apply_html_entities |
|
264 | + * |
|
265 | + * @return string |
|
266 | + */ |
|
267 | + public function full_name($apply_html_entities = false) |
|
268 | + { |
|
269 | + $full_name = $this->fname() . ' ' . $this->lname(); |
|
270 | 270 | |
271 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * get Attendee Last Name |
|
277 | - * |
|
278 | - * @access public |
|
279 | - * @return string |
|
280 | - */ |
|
281 | - public function lname() |
|
282 | - { |
|
283 | - return $this->get('ATT_lname'); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
289 | - * |
|
290 | - * @return array numerically indexed, with each part of the address that is known. |
|
291 | - * Eg, if the user only responded to state and country, |
|
292 | - * it would be array(0=>'Alabama',1=>'USA') |
|
293 | - * @return array |
|
294 | - */ |
|
295 | - public function full_address_as_array() |
|
296 | - { |
|
297 | - $full_address_array = array(); |
|
298 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
299 | - foreach ($initial_address_fields as $address_field_name) { |
|
300 | - $address_fields_value = $this->get($address_field_name); |
|
301 | - if ( ! empty($address_fields_value)) { |
|
302 | - $full_address_array[] = $address_fields_value; |
|
303 | - } |
|
304 | - } |
|
305 | - //now handle state and country |
|
306 | - $state_obj = $this->state_obj(); |
|
307 | - if ( ! empty($state_obj)) { |
|
308 | - $full_address_array[] = $state_obj->name(); |
|
309 | - } |
|
310 | - $country_obj = $this->country_obj(); |
|
311 | - if ( ! empty($country_obj)) { |
|
312 | - $full_address_array[] = $country_obj->name(); |
|
313 | - } |
|
314 | - //lastly get the xip |
|
315 | - $zip_value = $this->zip(); |
|
316 | - if ( ! empty($zip_value)) { |
|
317 | - $full_address_array[] = $zip_value; |
|
318 | - } |
|
271 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * get Attendee Last Name |
|
277 | + * |
|
278 | + * @access public |
|
279 | + * @return string |
|
280 | + */ |
|
281 | + public function lname() |
|
282 | + { |
|
283 | + return $this->get('ATT_lname'); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
289 | + * |
|
290 | + * @return array numerically indexed, with each part of the address that is known. |
|
291 | + * Eg, if the user only responded to state and country, |
|
292 | + * it would be array(0=>'Alabama',1=>'USA') |
|
293 | + * @return array |
|
294 | + */ |
|
295 | + public function full_address_as_array() |
|
296 | + { |
|
297 | + $full_address_array = array(); |
|
298 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
299 | + foreach ($initial_address_fields as $address_field_name) { |
|
300 | + $address_fields_value = $this->get($address_field_name); |
|
301 | + if ( ! empty($address_fields_value)) { |
|
302 | + $full_address_array[] = $address_fields_value; |
|
303 | + } |
|
304 | + } |
|
305 | + //now handle state and country |
|
306 | + $state_obj = $this->state_obj(); |
|
307 | + if ( ! empty($state_obj)) { |
|
308 | + $full_address_array[] = $state_obj->name(); |
|
309 | + } |
|
310 | + $country_obj = $this->country_obj(); |
|
311 | + if ( ! empty($country_obj)) { |
|
312 | + $full_address_array[] = $country_obj->name(); |
|
313 | + } |
|
314 | + //lastly get the xip |
|
315 | + $zip_value = $this->zip(); |
|
316 | + if ( ! empty($zip_value)) { |
|
317 | + $full_address_array[] = $zip_value; |
|
318 | + } |
|
319 | 319 | |
320 | - return $full_address_array; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * get Attendee Address |
|
326 | - * |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function address() |
|
330 | - { |
|
331 | - return $this->get('ATT_address'); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * get Attendee Address2 |
|
337 | - * |
|
338 | - * @return string |
|
339 | - */ |
|
340 | - public function address2() |
|
341 | - { |
|
342 | - return $this->get('ATT_address2'); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * get Attendee City |
|
348 | - * |
|
349 | - * @return string |
|
350 | - */ |
|
351 | - public function city() |
|
352 | - { |
|
353 | - return $this->get('ATT_city'); |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * get Attendee State ID |
|
359 | - * |
|
360 | - * @return string |
|
361 | - */ |
|
362 | - public function state_ID() |
|
363 | - { |
|
364 | - return $this->get('STA_ID'); |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * @return string |
|
370 | - */ |
|
371 | - public function state_abbrev() |
|
372 | - { |
|
373 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * Gets the state set to this attendee |
|
379 | - * |
|
380 | - * @return EE_State |
|
381 | - */ |
|
382 | - public function state_obj() |
|
383 | - { |
|
384 | - return $this->get_first_related('State'); |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * Returns the state's name, otherwise 'Unknown' |
|
390 | - * |
|
391 | - * @return string |
|
392 | - */ |
|
393 | - public function state_name() |
|
394 | - { |
|
395 | - if ($this->state_obj()) { |
|
396 | - return $this->state_obj()->name(); |
|
397 | - } else { |
|
398 | - return ''; |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * either displays the state abbreviation or the state name, as determined |
|
405 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
406 | - * defaults to abbreviation |
|
407 | - * |
|
408 | - * @return string |
|
409 | - */ |
|
410 | - public function state() |
|
411 | - { |
|
412 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
413 | - return $this->state_abbrev(); |
|
414 | - } else { |
|
415 | - return $this->state_name(); |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * get Attendee Country ISO Code |
|
422 | - * |
|
423 | - * @return string |
|
424 | - */ |
|
425 | - public function country_ID() |
|
426 | - { |
|
427 | - return $this->get('CNT_ISO'); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * Gets country set for this attendee |
|
433 | - * |
|
434 | - * @return EE_Country |
|
435 | - */ |
|
436 | - public function country_obj() |
|
437 | - { |
|
438 | - return $this->get_first_related('Country'); |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * Returns the country's name if known, otherwise 'Unknown' |
|
444 | - * |
|
445 | - * @return string |
|
446 | - */ |
|
447 | - public function country_name() |
|
448 | - { |
|
449 | - if ($this->country_obj()) { |
|
450 | - return $this->country_obj()->name(); |
|
451 | - } else { |
|
452 | - return ''; |
|
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * either displays the country ISO2 code or the country name, as determined |
|
459 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
460 | - * defaults to abbreviation |
|
461 | - * |
|
462 | - * @return string |
|
463 | - */ |
|
464 | - public function country() |
|
465 | - { |
|
466 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
467 | - return $this->country_ID(); |
|
468 | - } else { |
|
469 | - return $this->country_name(); |
|
470 | - } |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * get Attendee Zip/Postal Code |
|
476 | - * |
|
477 | - * @return string |
|
478 | - */ |
|
479 | - public function zip() |
|
480 | - { |
|
481 | - return $this->get('ATT_zip'); |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * get Attendee Email Address |
|
487 | - * |
|
488 | - * @return string |
|
489 | - */ |
|
490 | - public function email() |
|
491 | - { |
|
492 | - return $this->get('ATT_email'); |
|
493 | - } |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * get Attendee Phone # |
|
498 | - * |
|
499 | - * @return string |
|
500 | - */ |
|
501 | - public function phone() |
|
502 | - { |
|
503 | - return $this->get('ATT_phone'); |
|
504 | - } |
|
505 | - |
|
506 | - |
|
507 | - /** |
|
508 | - * get deleted |
|
509 | - * |
|
510 | - * @return bool |
|
511 | - */ |
|
512 | - public function deleted() |
|
513 | - { |
|
514 | - return $this->get('ATT_deleted'); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * Gets registrations of this attendee |
|
520 | - * |
|
521 | - * @param array $query_params |
|
522 | - * |
|
523 | - * @return EE_Registration[] |
|
524 | - */ |
|
525 | - public function get_registrations($query_params = array()) |
|
526 | - { |
|
527 | - return $this->get_many_related('Registration', $query_params); |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * Gets the most recent registration of this attendee |
|
533 | - * |
|
534 | - * @return EE_Registration |
|
535 | - */ |
|
536 | - public function get_most_recent_registration() |
|
537 | - { |
|
538 | - return $this->get_first_related('Registration', |
|
539 | - array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - /** |
|
544 | - * Gets the most recent registration for this attend at this event |
|
545 | - * |
|
546 | - * @param int $event_id |
|
547 | - * |
|
548 | - * @return EE_Registration |
|
549 | - */ |
|
550 | - public function get_most_recent_registration_for_event($event_id) |
|
551 | - { |
|
552 | - return $this->get_first_related('Registration', |
|
553 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * returns any events attached to this attendee ($_Event property); |
|
559 | - * |
|
560 | - * @return array |
|
561 | - */ |
|
562 | - public function events() |
|
563 | - { |
|
564 | - return $this->get_many_related('Event'); |
|
565 | - } |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
570 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
571 | - * used to save the billing info |
|
572 | - * |
|
573 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
574 | - * |
|
575 | - * @return EE_Form_Section_Proper|null |
|
576 | - */ |
|
577 | - public function billing_info_for_payment_method($payment_method) |
|
578 | - { |
|
579 | - $pm_type = $payment_method->type_obj(); |
|
580 | - if ( ! $pm_type instanceof EE_PMT_Base) { |
|
581 | - return null; |
|
582 | - } |
|
583 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
584 | - if ( ! $billing_info) { |
|
585 | - return null; |
|
586 | - } |
|
587 | - $billing_form = $pm_type->billing_form(); |
|
588 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
589 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
590 | - } |
|
320 | + return $full_address_array; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * get Attendee Address |
|
326 | + * |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function address() |
|
330 | + { |
|
331 | + return $this->get('ATT_address'); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * get Attendee Address2 |
|
337 | + * |
|
338 | + * @return string |
|
339 | + */ |
|
340 | + public function address2() |
|
341 | + { |
|
342 | + return $this->get('ATT_address2'); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * get Attendee City |
|
348 | + * |
|
349 | + * @return string |
|
350 | + */ |
|
351 | + public function city() |
|
352 | + { |
|
353 | + return $this->get('ATT_city'); |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * get Attendee State ID |
|
359 | + * |
|
360 | + * @return string |
|
361 | + */ |
|
362 | + public function state_ID() |
|
363 | + { |
|
364 | + return $this->get('STA_ID'); |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * @return string |
|
370 | + */ |
|
371 | + public function state_abbrev() |
|
372 | + { |
|
373 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * Gets the state set to this attendee |
|
379 | + * |
|
380 | + * @return EE_State |
|
381 | + */ |
|
382 | + public function state_obj() |
|
383 | + { |
|
384 | + return $this->get_first_related('State'); |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * Returns the state's name, otherwise 'Unknown' |
|
390 | + * |
|
391 | + * @return string |
|
392 | + */ |
|
393 | + public function state_name() |
|
394 | + { |
|
395 | + if ($this->state_obj()) { |
|
396 | + return $this->state_obj()->name(); |
|
397 | + } else { |
|
398 | + return ''; |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * either displays the state abbreviation or the state name, as determined |
|
405 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
406 | + * defaults to abbreviation |
|
407 | + * |
|
408 | + * @return string |
|
409 | + */ |
|
410 | + public function state() |
|
411 | + { |
|
412 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
413 | + return $this->state_abbrev(); |
|
414 | + } else { |
|
415 | + return $this->state_name(); |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * get Attendee Country ISO Code |
|
422 | + * |
|
423 | + * @return string |
|
424 | + */ |
|
425 | + public function country_ID() |
|
426 | + { |
|
427 | + return $this->get('CNT_ISO'); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * Gets country set for this attendee |
|
433 | + * |
|
434 | + * @return EE_Country |
|
435 | + */ |
|
436 | + public function country_obj() |
|
437 | + { |
|
438 | + return $this->get_first_related('Country'); |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * Returns the country's name if known, otherwise 'Unknown' |
|
444 | + * |
|
445 | + * @return string |
|
446 | + */ |
|
447 | + public function country_name() |
|
448 | + { |
|
449 | + if ($this->country_obj()) { |
|
450 | + return $this->country_obj()->name(); |
|
451 | + } else { |
|
452 | + return ''; |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * either displays the country ISO2 code or the country name, as determined |
|
459 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
460 | + * defaults to abbreviation |
|
461 | + * |
|
462 | + * @return string |
|
463 | + */ |
|
464 | + public function country() |
|
465 | + { |
|
466 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
467 | + return $this->country_ID(); |
|
468 | + } else { |
|
469 | + return $this->country_name(); |
|
470 | + } |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * get Attendee Zip/Postal Code |
|
476 | + * |
|
477 | + * @return string |
|
478 | + */ |
|
479 | + public function zip() |
|
480 | + { |
|
481 | + return $this->get('ATT_zip'); |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * get Attendee Email Address |
|
487 | + * |
|
488 | + * @return string |
|
489 | + */ |
|
490 | + public function email() |
|
491 | + { |
|
492 | + return $this->get('ATT_email'); |
|
493 | + } |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * get Attendee Phone # |
|
498 | + * |
|
499 | + * @return string |
|
500 | + */ |
|
501 | + public function phone() |
|
502 | + { |
|
503 | + return $this->get('ATT_phone'); |
|
504 | + } |
|
505 | + |
|
506 | + |
|
507 | + /** |
|
508 | + * get deleted |
|
509 | + * |
|
510 | + * @return bool |
|
511 | + */ |
|
512 | + public function deleted() |
|
513 | + { |
|
514 | + return $this->get('ATT_deleted'); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * Gets registrations of this attendee |
|
520 | + * |
|
521 | + * @param array $query_params |
|
522 | + * |
|
523 | + * @return EE_Registration[] |
|
524 | + */ |
|
525 | + public function get_registrations($query_params = array()) |
|
526 | + { |
|
527 | + return $this->get_many_related('Registration', $query_params); |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * Gets the most recent registration of this attendee |
|
533 | + * |
|
534 | + * @return EE_Registration |
|
535 | + */ |
|
536 | + public function get_most_recent_registration() |
|
537 | + { |
|
538 | + return $this->get_first_related('Registration', |
|
539 | + array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + /** |
|
544 | + * Gets the most recent registration for this attend at this event |
|
545 | + * |
|
546 | + * @param int $event_id |
|
547 | + * |
|
548 | + * @return EE_Registration |
|
549 | + */ |
|
550 | + public function get_most_recent_registration_for_event($event_id) |
|
551 | + { |
|
552 | + return $this->get_first_related('Registration', |
|
553 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * returns any events attached to this attendee ($_Event property); |
|
559 | + * |
|
560 | + * @return array |
|
561 | + */ |
|
562 | + public function events() |
|
563 | + { |
|
564 | + return $this->get_many_related('Event'); |
|
565 | + } |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
570 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
571 | + * used to save the billing info |
|
572 | + * |
|
573 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
574 | + * |
|
575 | + * @return EE_Form_Section_Proper|null |
|
576 | + */ |
|
577 | + public function billing_info_for_payment_method($payment_method) |
|
578 | + { |
|
579 | + $pm_type = $payment_method->type_obj(); |
|
580 | + if ( ! $pm_type instanceof EE_PMT_Base) { |
|
581 | + return null; |
|
582 | + } |
|
583 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
584 | + if ( ! $billing_info) { |
|
585 | + return null; |
|
586 | + } |
|
587 | + $billing_form = $pm_type->billing_form(); |
|
588 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
589 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
590 | + } |
|
591 | 591 | |
592 | - return $billing_form; |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - /** |
|
597 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
598 | - * specified payment method |
|
599 | - * |
|
600 | - * @param EE_Payment_Method $payment_method |
|
601 | - * |
|
602 | - * @return string |
|
603 | - */ |
|
604 | - public function get_billing_info_postmeta_name($payment_method) |
|
605 | - { |
|
606 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
607 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
608 | - } else { |
|
609 | - return null; |
|
610 | - } |
|
611 | - } |
|
612 | - |
|
613 | - |
|
614 | - /** |
|
615 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
616 | - * retrieve it |
|
617 | - * |
|
618 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
619 | - * @param EE_Payment_Method $payment_method |
|
620 | - * |
|
621 | - * @return boolean |
|
622 | - */ |
|
623 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
624 | - { |
|
625 | - if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
626 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
592 | + return $billing_form; |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + /** |
|
597 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
598 | + * specified payment method |
|
599 | + * |
|
600 | + * @param EE_Payment_Method $payment_method |
|
601 | + * |
|
602 | + * @return string |
|
603 | + */ |
|
604 | + public function get_billing_info_postmeta_name($payment_method) |
|
605 | + { |
|
606 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
607 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
608 | + } else { |
|
609 | + return null; |
|
610 | + } |
|
611 | + } |
|
612 | + |
|
613 | + |
|
614 | + /** |
|
615 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
616 | + * retrieve it |
|
617 | + * |
|
618 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
619 | + * @param EE_Payment_Method $payment_method |
|
620 | + * |
|
621 | + * @return boolean |
|
622 | + */ |
|
623 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
624 | + { |
|
625 | + if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
626 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
627 | 627 | |
628 | - return false; |
|
629 | - } |
|
630 | - $billing_form->clean_sensitive_data(); |
|
628 | + return false; |
|
629 | + } |
|
630 | + $billing_form->clean_sensitive_data(); |
|
631 | 631 | |
632 | - return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), |
|
633 | - $billing_form->input_values(true)); |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * Return the link to the admin details for the object. |
|
639 | - * |
|
640 | - * @return string |
|
641 | - */ |
|
642 | - public function get_admin_details_link() |
|
643 | - { |
|
644 | - return $this->get_admin_edit_link(); |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
650 | - * |
|
651 | - * @return string |
|
652 | - */ |
|
653 | - public function get_admin_edit_link() |
|
654 | - { |
|
655 | - EE_Registry::instance()->load_helper('URL'); |
|
632 | + return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), |
|
633 | + $billing_form->input_values(true)); |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * Return the link to the admin details for the object. |
|
639 | + * |
|
640 | + * @return string |
|
641 | + */ |
|
642 | + public function get_admin_details_link() |
|
643 | + { |
|
644 | + return $this->get_admin_edit_link(); |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
650 | + * |
|
651 | + * @return string |
|
652 | + */ |
|
653 | + public function get_admin_edit_link() |
|
654 | + { |
|
655 | + EE_Registry::instance()->load_helper('URL'); |
|
656 | 656 | |
657 | - return EEH_URL::add_query_args_and_nonce( |
|
658 | - array( |
|
659 | - 'page' => 'espresso_registrations', |
|
660 | - 'action' => 'edit_attendee', |
|
661 | - 'post' => $this->ID(), |
|
662 | - ), |
|
663 | - admin_url('admin.php') |
|
664 | - ); |
|
665 | - } |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * Returns the link to a settings page for the object. |
|
670 | - * |
|
671 | - * @return string |
|
672 | - */ |
|
673 | - public function get_admin_settings_link() |
|
674 | - { |
|
675 | - return $this->get_admin_edit_link(); |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - /** |
|
680 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
681 | - * |
|
682 | - * @return string |
|
683 | - */ |
|
684 | - public function get_admin_overview_link() |
|
685 | - { |
|
686 | - EE_Registry::instance()->load_helper('URL'); |
|
657 | + return EEH_URL::add_query_args_and_nonce( |
|
658 | + array( |
|
659 | + 'page' => 'espresso_registrations', |
|
660 | + 'action' => 'edit_attendee', |
|
661 | + 'post' => $this->ID(), |
|
662 | + ), |
|
663 | + admin_url('admin.php') |
|
664 | + ); |
|
665 | + } |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * Returns the link to a settings page for the object. |
|
670 | + * |
|
671 | + * @return string |
|
672 | + */ |
|
673 | + public function get_admin_settings_link() |
|
674 | + { |
|
675 | + return $this->get_admin_edit_link(); |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + /** |
|
680 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
681 | + * |
|
682 | + * @return string |
|
683 | + */ |
|
684 | + public function get_admin_overview_link() |
|
685 | + { |
|
686 | + EE_Registry::instance()->load_helper('URL'); |
|
687 | 687 | |
688 | - return EEH_URL::add_query_args_and_nonce( |
|
689 | - array( |
|
690 | - 'page' => 'espresso_registrations', |
|
691 | - 'action' => 'contact_list', |
|
692 | - ), |
|
693 | - admin_url('admin.php') |
|
694 | - ); |
|
695 | - } |
|
688 | + return EEH_URL::add_query_args_and_nonce( |
|
689 | + array( |
|
690 | + 'page' => 'espresso_registrations', |
|
691 | + 'action' => 'contact_list', |
|
692 | + ), |
|
693 | + admin_url('admin.php') |
|
694 | + ); |
|
695 | + } |
|
696 | 696 | |
697 | 697 | |
698 | 698 | } |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
35 | 35 | { |
36 | 36 | if ( ! isset($fieldValues['ATT_full_name'])) { |
37 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
37 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : ''; |
|
38 | 38 | $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
39 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
39 | + $fieldValues['ATT_full_name'] = $fname.$lname; |
|
40 | 40 | } |
41 | 41 | if ( ! isset($fieldValues['ATT_slug'])) { |
42 | 42 | // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function full_name($apply_html_entities = false) |
268 | 268 | { |
269 | - $full_name = $this->fname() . ' ' . $this->lname(); |
|
269 | + $full_name = $this->fname().' '.$this->lname(); |
|
270 | 270 | |
271 | 271 | return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
272 | 272 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | public function get_most_recent_registration_for_event($event_id) |
551 | 551 | { |
552 | 552 | return $this->get_first_related('Registration', |
553 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
553 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))); //, '=', 'OBJECT_K' ); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | public function get_billing_info_postmeta_name($payment_method) |
605 | 605 | { |
606 | 606 | if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
607 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
607 | + return 'billing_info_'.$payment_method->type_obj()->system_name(); |
|
608 | 608 | } else { |
609 | 609 | return null; |
610 | 610 | } |
@@ -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 | * EEH_Activation Helper |
4 | 4 | * |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @return \EventEspresso\core\services\database\TableAnalysis |
55 | 55 | */ |
56 | 56 | public static function getTableAnalysis() { |
57 | - if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis ) { |
|
58 | - self::$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
57 | + if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
58 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
59 | 59 | } |
60 | 60 | return self::$table_analysis; |
61 | 61 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @return \EventEspresso\core\services\database\TableManager |
67 | 67 | */ |
68 | 68 | public static function getTableManager() { |
69 | - if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager ) { |
|
70 | - self::$table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
69 | + if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
70 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
71 | 71 | } |
72 | 72 | return self::$table_manager; |
73 | 73 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param $table_name |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
86 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
85 | + public static function ensure_table_name_has_prefix($table_name) { |
|
86 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return boolean success, whether the database and folders are setup properly |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public static function initialize_db_and_folders(){ |
|
114 | + public static function initialize_db_and_folders() { |
|
115 | 115 | $good_filesystem = EEH_Activation::create_upload_directories(); |
116 | 116 | $good_db = EEH_Activation::create_database_tables(); |
117 | 117 | return $good_filesystem && $good_db; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | - public static function initialize_db_content(){ |
|
130 | + public static function initialize_db_content() { |
|
131 | 131 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
132 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
132 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | EEH_Activation::remove_cron_tasks(); |
147 | 147 | EEH_Activation::create_cron_tasks(); |
148 | 148 | // remove all TXN locks since that is being done via extra meta now |
149 | - delete_option( 'ee_locked_transactions' ); |
|
149 | + delete_option('ee_locked_transactions'); |
|
150 | 150 | //also, check for CAF default db content |
151 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
151 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
152 | 152 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
153 | 153 | //which users really won't care about on initial activation |
154 | 154 | EE_Error::overwrite_success(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return array |
169 | 169 | * @throws \EE_Error |
170 | 170 | */ |
171 | - public static function get_cron_tasks( $which_to_include ) { |
|
171 | + public static function get_cron_tasks($which_to_include) { |
|
172 | 172 | $cron_tasks = apply_filters( |
173 | 173 | 'FHEE__EEH_Activation__get_cron_tasks', |
174 | 174 | array( |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
178 | 178 | ) |
179 | 179 | ); |
180 | - if ( $which_to_include === 'old' ) { |
|
180 | + if ($which_to_include === 'old') { |
|
181 | 181 | $cron_tasks = array_filter( |
182 | 182 | $cron_tasks, |
183 | - function ( $value ) { |
|
183 | + function($value) { |
|
184 | 184 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
185 | 185 | } |
186 | 186 | ); |
187 | - } elseif ( $which_to_include === 'current' ) { |
|
188 | - $cron_tasks = array_filter( $cron_tasks ); |
|
189 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
187 | + } elseif ($which_to_include === 'current') { |
|
188 | + $cron_tasks = array_filter($cron_tasks); |
|
189 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
190 | 190 | throw new EE_Error( |
191 | 191 | sprintf( |
192 | 192 | __( |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public static function create_cron_tasks() { |
211 | 211 | |
212 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
213 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
214 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
212 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
213 | + if ( ! wp_next_scheduled($hook_name)) { |
|
214 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
226 | 226 | * @throws \EE_Error |
227 | 227 | */ |
228 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
228 | + public static function remove_cron_tasks($remove_all = true) { |
|
229 | 229 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
230 | 230 | $crons = _get_cron_array(); |
231 | - $crons = is_array( $crons ) ? $crons : array(); |
|
231 | + $crons = is_array($crons) ? $crons : array(); |
|
232 | 232 | /* reminder of what $crons look like: |
233 | 233 | * Top-level keys are timestamps, and their values are arrays. |
234 | 234 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -246,23 +246,23 @@ discard block |
||
246 | 246 | * ... |
247 | 247 | * ... |
248 | 248 | */ |
249 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
250 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
251 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
252 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
253 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
254 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
249 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
250 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
251 | + if (is_array($hooks_to_fire_at_time)) { |
|
252 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
253 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
254 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
255 | 255 | ) { |
256 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
256 | + unset($crons[$timestamp][$hook_name]); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | //also take care of any empty cron timestamps. |
260 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
261 | - unset( $crons[ $timestamp ] ); |
|
260 | + if (empty($hooks_to_fire_at_time)) { |
|
261 | + unset($crons[$timestamp]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
265 | - _set_cron_array( $crons ); |
|
265 | + _set_cron_array($crons); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function CPT_initialization() { |
279 | 279 | // register Custom Post Types |
280 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
280 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
281 | 281 | flush_rewrite_rules(); |
282 | 282 | } |
283 | 283 | |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | * @return void |
296 | 296 | */ |
297 | 297 | public static function reset_and_update_config() { |
298 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
299 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
298 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
299 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
300 | 300 | //EE_Config::reset(); |
301 | - if ( ! EE_Config::logging_enabled() ) { |
|
302 | - delete_option( EE_Config::LOG_NAME ); |
|
301 | + if ( ! EE_Config::logging_enabled()) { |
|
302 | + delete_option(EE_Config::LOG_NAME); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -312,28 +312,28 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public static function load_calendar_config() { |
314 | 314 | // grab array of all plugin folders and loop thru it |
315 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
316 | - if ( empty( $plugins ) ) { |
|
315 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
316 | + if (empty($plugins)) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | - foreach ( $plugins as $plugin_path ) { |
|
319 | + foreach ($plugins as $plugin_path) { |
|
320 | 320 | // grab plugin folder name from path |
321 | - $plugin = basename( $plugin_path ); |
|
321 | + $plugin = basename($plugin_path); |
|
322 | 322 | // drill down to Espresso plugins |
323 | 323 | // then to calendar related plugins |
324 | 324 | if ( |
325 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
326 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
327 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
328 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
329 | - || strpos( $plugin, 'calendar' ) !== false |
|
325 | + strpos($plugin, 'espresso') !== FALSE |
|
326 | + || strpos($plugin, 'Espresso') !== FALSE |
|
327 | + || strpos($plugin, 'ee4') !== FALSE |
|
328 | + || strpos($plugin, 'EE4') !== FALSE |
|
329 | + || strpos($plugin, 'calendar') !== false |
|
330 | 330 | ) { |
331 | 331 | // this is what we are looking for |
332 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
332 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
333 | 333 | // does it exist in this folder ? |
334 | - if ( is_readable( $calendar_config )) { |
|
334 | + if (is_readable($calendar_config)) { |
|
335 | 335 | // YEAH! let's load it |
336 | - require_once( $calendar_config ); |
|
336 | + require_once($calendar_config); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | } |
@@ -349,21 +349,21 @@ discard block |
||
349 | 349 | * @param \EE_Config $EE_Config |
350 | 350 | * @return \stdClass |
351 | 351 | */ |
352 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
353 | - $convert_from_array = array( 'addons' ); |
|
352 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
353 | + $convert_from_array = array('addons'); |
|
354 | 354 | // in case old settings were saved as an array |
355 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
355 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
356 | 356 | // convert existing settings to an object |
357 | 357 | $config_array = $settings; |
358 | 358 | $settings = new stdClass(); |
359 | - foreach ( $config_array as $key => $value ){ |
|
360 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
361 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
359 | + foreach ($config_array as $key => $value) { |
|
360 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
361 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
362 | 362 | } else { |
363 | 363 | $settings->{$key} = $value; |
364 | 364 | } |
365 | 365 | } |
366 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
366 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
367 | 367 | } |
368 | 368 | return $settings; |
369 | 369 | } |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public static function deactivate_event_espresso() { |
381 | 381 | // check permissions |
382 | - if ( current_user_can( 'activate_plugins' )) { |
|
383 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
382 | + if (current_user_can('activate_plugins')) { |
|
383 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
@@ -402,25 +402,25 @@ discard block |
||
402 | 402 | $critical_pages = array( |
403 | 403 | array( |
404 | 404 | 'id' =>'reg_page_id', |
405 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
405 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
406 | 406 | 'post' => NULL, |
407 | 407 | 'code' => 'ESPRESSO_CHECKOUT' |
408 | 408 | ), |
409 | 409 | array( |
410 | 410 | 'id' => 'txn_page_id', |
411 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
411 | + 'name' => __('Transactions', 'event_espresso'), |
|
412 | 412 | 'post' => NULL, |
413 | 413 | 'code' => 'ESPRESSO_TXN_PAGE' |
414 | 414 | ), |
415 | 415 | array( |
416 | 416 | 'id' => 'thank_you_page_id', |
417 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
417 | + 'name' => __('Thank You', 'event_espresso'), |
|
418 | 418 | 'post' => NULL, |
419 | 419 | 'code' => 'ESPRESSO_THANK_YOU' |
420 | 420 | ), |
421 | 421 | array( |
422 | 422 | 'id' => 'cancel_page_id', |
423 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
423 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
424 | 424 | 'post' => NULL, |
425 | 425 | 'code' => 'ESPRESSO_CANCELLED' |
426 | 426 | ), |
@@ -428,62 +428,62 @@ discard block |
||
428 | 428 | |
429 | 429 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
430 | 430 | |
431 | - foreach ( $critical_pages as $critical_page ) { |
|
431 | + foreach ($critical_pages as $critical_page) { |
|
432 | 432 | // is critical page ID set in config ? |
433 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
433 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
434 | 434 | // attempt to find post by ID |
435 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
435 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
436 | 436 | } |
437 | 437 | // no dice? |
438 | - if ( $critical_page['post'] === null ) { |
|
438 | + if ($critical_page['post'] === null) { |
|
439 | 439 | // attempt to find post by title |
440 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
440 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
441 | 441 | // still nothing? |
442 | - if ( $critical_page['post'] === null ) { |
|
443 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
442 | + if ($critical_page['post'] === null) { |
|
443 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
444 | 444 | // REALLY? Still nothing ??!?!? |
445 | - if ( $critical_page['post'] === null ) { |
|
446 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
447 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
445 | + if ($critical_page['post'] === null) { |
|
446 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
447 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
448 | 448 | break; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | } |
452 | 452 | // track post_shortcodes |
453 | - if ( $critical_page['post'] ) { |
|
454 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
453 | + if ($critical_page['post']) { |
|
454 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
455 | 455 | } |
456 | 456 | // check that Post ID matches critical page ID in config |
457 | 457 | if ( |
458 | - isset( $critical_page['post']->ID ) |
|
459 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
458 | + isset($critical_page['post']->ID) |
|
459 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
460 | 460 | ) { |
461 | 461 | //update Config with post ID |
462 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
463 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
464 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
465 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
462 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
463 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
464 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
465 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | 469 | $critical_page_problem = |
470 | - ! isset( $critical_page['post']->post_status ) |
|
470 | + ! isset($critical_page['post']->post_status) |
|
471 | 471 | || $critical_page['post']->post_status !== 'publish' |
472 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
472 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
473 | 473 | ? TRUE |
474 | 474 | : $critical_page_problem; |
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - if ( $critical_page_problem ) { |
|
478 | + if ($critical_page_problem) { |
|
479 | 479 | $msg = sprintf( |
480 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
481 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
480 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
481 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
482 | 482 | ); |
483 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
483 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
484 | 484 | } |
485 | - if ( EE_Error::has_notices() ) { |
|
486 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
485 | + if (EE_Error::has_notices()) { |
|
486 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | * parameter to the shortcode |
496 | 496 | * @return WP_Post or NULl |
497 | 497 | */ |
498 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
498 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
499 | 499 | global $wpdb; |
500 | 500 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
501 | 501 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
502 | - if($post_id){ |
|
502 | + if ($post_id) { |
|
503 | 503 | return get_post($post_id); |
504 | - }else{ |
|
504 | + } else { |
|
505 | 505 | return NULL; |
506 | 506 | } |
507 | 507 | |
@@ -518,32 +518,32 @@ discard block |
||
518 | 518 | * @param array $critical_page |
519 | 519 | * @return array |
520 | 520 | */ |
521 | - public static function create_critical_page( $critical_page ) { |
|
521 | + public static function create_critical_page($critical_page) { |
|
522 | 522 | |
523 | 523 | $post_args = array( |
524 | 524 | 'post_title' => $critical_page['name'], |
525 | 525 | 'post_status' => 'publish', |
526 | 526 | 'post_type' => 'page', |
527 | 527 | 'comment_status' => 'closed', |
528 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
528 | + 'post_content' => '['.$critical_page['code'].']' |
|
529 | 529 | ); |
530 | 530 | |
531 | - $post_id = wp_insert_post( $post_args ); |
|
532 | - if ( ! $post_id ) { |
|
531 | + $post_id = wp_insert_post($post_args); |
|
532 | + if ( ! $post_id) { |
|
533 | 533 | $msg = sprintf( |
534 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
534 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
535 | 535 | $critical_page['name'] |
536 | 536 | ); |
537 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
537 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
538 | 538 | return $critical_page; |
539 | 539 | } |
540 | 540 | // get newly created post's details |
541 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
541 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
542 | 542 | $msg = sprintf( |
543 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
543 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
544 | 544 | $critical_page['name'] |
545 | 545 | ); |
546 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
546 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $critical_page; |
@@ -562,35 +562,35 @@ discard block |
||
562 | 562 | * @param array $critical_page |
563 | 563 | * @return void |
564 | 564 | */ |
565 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
565 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
566 | 566 | // check the goods |
567 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
567 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
568 | 568 | $msg = sprintf( |
569 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
569 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
570 | 570 | $critical_page['name'] |
571 | 571 | ); |
572 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
572 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
576 | 576 | // map shortcode to post |
577 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
577 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
578 | 578 | // and make sure it's NOT added to the WP "Posts Page" |
579 | 579 | // name of the WP Posts Page |
580 | 580 | $posts_page = EE_Config::get_page_for_posts(); |
581 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
582 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
581 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
582 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
583 | 583 | } |
584 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
585 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
584 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
585 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
586 | 586 | } |
587 | 587 | // update post_shortcode CFG |
588 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
588 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
589 | 589 | $msg = sprintf( |
590 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
590 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
591 | 591 | $critical_page['name'] |
592 | 592 | ); |
593 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
593 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
@@ -608,24 +608,24 @@ discard block |
||
608 | 608 | public static function get_default_creator_id() { |
609 | 609 | global $wpdb; |
610 | 610 | |
611 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
611 | + if ( ! empty(self::$_default_creator_id)) { |
|
612 | 612 | return self::$_default_creator_id; |
613 | 613 | }/**/ |
614 | 614 | |
615 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
615 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
616 | 616 | |
617 | 617 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
618 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
619 | - if ( $pre_filtered_id !== false ) { |
|
618 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
619 | + if ($pre_filtered_id !== false) { |
|
620 | 620 | return (int) $pre_filtered_id; |
621 | 621 | } |
622 | 622 | |
623 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'capabilities' ); |
|
624 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
625 | - $user_id = $wpdb->get_var( $query ); |
|
626 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
627 | - if ( $user_id && (int)$user_id ) { |
|
628 | - self::$_default_creator_id = (int)$user_id; |
|
623 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
624 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
625 | + $user_id = $wpdb->get_var($query); |
|
626 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
627 | + if ($user_id && (int) $user_id) { |
|
628 | + self::$_default_creator_id = (int) $user_id; |
|
629 | 629 | return self::$_default_creator_id; |
630 | 630 | } else { |
631 | 631 | return NULL; |
@@ -654,28 +654,28 @@ discard block |
||
654 | 654 | * @return void |
655 | 655 | * @throws EE_Error if there are database errors |
656 | 656 | */ |
657 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
658 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
657 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
658 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
659 | 659 | return; |
660 | 660 | } |
661 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
662 | - if ( ! function_exists( 'dbDelta' )) { |
|
663 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
661 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
662 | + if ( ! function_exists('dbDelta')) { |
|
663 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
664 | 664 | } |
665 | 665 | $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
666 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix( $table_name ); |
|
666 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
667 | 667 | // do we need to first delete an existing version of this table ? |
668 | - if ( $drop_pre_existing_table && $tableAnalysis->tableExists( $wp_table_name ) ){ |
|
668 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
669 | 669 | // ok, delete the table... but ONLY if it's empty |
670 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
670 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
671 | 671 | // table is NOT empty, are you SURE you want to delete this table ??? |
672 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
673 | - \EEH_Activation::getTableManager()->dropTable( $wp_table_name ); |
|
674 | - } else if ( ! $deleted_safely ) { |
|
672 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
673 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
674 | + } else if ( ! $deleted_safely) { |
|
675 | 675 | // so we should be more cautious rather than just dropping tables so easily |
676 | 676 | EE_Error::add_persistent_admin_notice( |
677 | - 'bad_table_' . $wp_table_name . '_detected', |
|
678 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
677 | + 'bad_table_'.$wp_table_name.'_detected', |
|
678 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
679 | 679 | $wp_table_name, |
680 | 680 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
681 | 681 | '<b>wp-config.php</b>', |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | TRUE ); |
684 | 684 | } |
685 | 685 | } |
686 | - $engine = str_replace( 'ENGINE=', '', $engine ); |
|
687 | - \EEH_Activation::getTableManager()->createTable( $table_name, $sql, $engine ); |
|
686 | + $engine = str_replace('ENGINE=', '', $engine); |
|
687 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * 'VARCHAR(10)' |
703 | 703 | * @return bool|int |
704 | 704 | */ |
705 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
706 | - return \EEH_Activation::getTableManager()->addColumn( $table_name, $column_name, $column_info ); |
|
705 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
706 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | * @param string $table_name, without prefixed $wpdb->prefix |
720 | 720 | * @return array of database column names |
721 | 721 | */ |
722 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
723 | - return \EEH_Activation::getTableManager()->getTableColumns( $table_name ); |
|
722 | + public static function get_fields_on_table($table_name = NULL) { |
|
723 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | * @param string $table_name |
735 | 735 | * @return bool |
736 | 736 | */ |
737 | - public static function db_table_is_empty( $table_name ) { |
|
738 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ); |
|
737 | + public static function db_table_is_empty($table_name) { |
|
738 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | |
@@ -748,9 +748,9 @@ discard block |
||
748 | 748 | * @param string $table_name |
749 | 749 | * @return bool | int |
750 | 750 | */ |
751 | - public static function delete_db_table_if_empty( $table_name ) { |
|
752 | - if ( \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ) ) { |
|
753 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
751 | + public static function delete_db_table_if_empty($table_name) { |
|
752 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
753 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
754 | 754 | } |
755 | 755 | return false; |
756 | 756 | } |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | * @param string $table_name |
767 | 767 | * @return bool | int |
768 | 768 | */ |
769 | - public static function delete_unused_db_table( $table_name ) { |
|
770 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
769 | + public static function delete_unused_db_table($table_name) { |
|
770 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | * @param string $index_name |
783 | 783 | * @return bool | int |
784 | 784 | */ |
785 | - public static function drop_index( $table_name, $index_name ) { |
|
786 | - return \EEH_Activation::getTableManager()->dropIndex( $table_name, $index_name ); |
|
785 | + public static function drop_index($table_name, $index_name) { |
|
786 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | |
@@ -797,27 +797,27 @@ discard block |
||
797 | 797 | * @return boolean success (whether database is setup properly or not) |
798 | 798 | */ |
799 | 799 | public static function create_database_tables() { |
800 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
800 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
801 | 801 | //find the migration script that sets the database to be compatible with the code |
802 | 802 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
803 | - if( $dms_name ){ |
|
804 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
805 | - $current_data_migration_script->set_migrating( false ); |
|
803 | + if ($dms_name) { |
|
804 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
805 | + $current_data_migration_script->set_migrating(false); |
|
806 | 806 | $current_data_migration_script->schema_changes_before_migration(); |
807 | 807 | $current_data_migration_script->schema_changes_after_migration(); |
808 | - if( $current_data_migration_script->get_errors() ){ |
|
809 | - if( WP_DEBUG ){ |
|
810 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
811 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
808 | + if ($current_data_migration_script->get_errors()) { |
|
809 | + if (WP_DEBUG) { |
|
810 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
811 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
812 | 812 | } |
813 | - }else{ |
|
814 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
813 | + } else { |
|
814 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
815 | 815 | } |
816 | 816 | return false; |
817 | 817 | } |
818 | 818 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
819 | - }else{ |
|
820 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
819 | + } else { |
|
820 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
821 | 821 | return false; |
822 | 822 | } |
823 | 823 | return true; |
@@ -837,27 +837,27 @@ discard block |
||
837 | 837 | public static function initialize_system_questions() { |
838 | 838 | // QUESTION GROUPS |
839 | 839 | global $wpdb; |
840 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group' ); |
|
840 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
841 | 841 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
842 | 842 | // what we have |
843 | - $question_groups = $wpdb->get_col( $SQL ); |
|
843 | + $question_groups = $wpdb->get_col($SQL); |
|
844 | 844 | // check the response |
845 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
845 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
846 | 846 | // what we should have |
847 | - $QSG_systems = array( 1, 2 ); |
|
847 | + $QSG_systems = array(1, 2); |
|
848 | 848 | // loop thru what we should have and compare to what we have |
849 | - foreach ( $QSG_systems as $QSG_system ) { |
|
849 | + foreach ($QSG_systems as $QSG_system) { |
|
850 | 850 | // reset values array |
851 | 851 | $QSG_values = array(); |
852 | 852 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
853 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
853 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
854 | 854 | // add it |
855 | - switch ( $QSG_system ) { |
|
855 | + switch ($QSG_system) { |
|
856 | 856 | |
857 | 857 | case 1: |
858 | 858 | $QSG_values = array( |
859 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
860 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
859 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
860 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
861 | 861 | 'QSG_desc' => '', |
862 | 862 | 'QSG_order' => 1, |
863 | 863 | 'QSG_show_group_name' => 1, |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | |
870 | 870 | case 2: |
871 | 871 | $QSG_values = array( |
872 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
873 | - 'QSG_identifier' => 'address-information-' . time(), |
|
872 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
873 | + 'QSG_identifier' => 'address-information-'.time(), |
|
874 | 874 | 'QSG_desc' => '', |
875 | 875 | 'QSG_order' => 2, |
876 | 876 | 'QSG_show_group_name' => 1, |
@@ -882,14 +882,14 @@ discard block |
||
882 | 882 | |
883 | 883 | } |
884 | 884 | // make sure we have some values before inserting them |
885 | - if ( ! empty( $QSG_values )) { |
|
885 | + if ( ! empty($QSG_values)) { |
|
886 | 886 | // insert system question |
887 | 887 | $wpdb->insert( |
888 | 888 | $table_name, |
889 | 889 | $QSG_values, |
890 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
890 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
891 | 891 | ); |
892 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
892 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | } |
@@ -898,10 +898,10 @@ discard block |
||
898 | 898 | |
899 | 899 | // QUESTIONS |
900 | 900 | global $wpdb; |
901 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question' ); |
|
901 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
902 | 902 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
903 | 903 | // what we have |
904 | - $questions = $wpdb->get_col( $SQL ); |
|
904 | + $questions = $wpdb->get_col($SQL); |
|
905 | 905 | // what we should have |
906 | 906 | $QST_systems = array( |
907 | 907 | 'fname', |
@@ -918,25 +918,25 @@ discard block |
||
918 | 918 | $order_for_group_1 = 1; |
919 | 919 | $order_for_group_2 = 1; |
920 | 920 | // loop thru what we should have and compare to what we have |
921 | - foreach ( $QST_systems as $QST_system ) { |
|
921 | + foreach ($QST_systems as $QST_system) { |
|
922 | 922 | // reset values array |
923 | 923 | $QST_values = array(); |
924 | 924 | // if we don't have what we should have |
925 | - if ( ! in_array( $QST_system, $questions )) { |
|
925 | + if ( ! in_array($QST_system, $questions)) { |
|
926 | 926 | // add it |
927 | - switch ( $QST_system ) { |
|
927 | + switch ($QST_system) { |
|
928 | 928 | |
929 | 929 | case 'fname': |
930 | 930 | $QST_values = array( |
931 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
932 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
931 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
932 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
933 | 933 | 'QST_system' => 'fname', |
934 | 934 | 'QST_type' => 'TEXT', |
935 | 935 | 'QST_required' => 1, |
936 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
936 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
937 | 937 | 'QST_order' => 1, |
938 | 938 | 'QST_admin_only' => 0, |
939 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
939 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
940 | 940 | 'QST_wp_user' => self::get_default_creator_id(), |
941 | 941 | 'QST_deleted' => 0 |
942 | 942 | ); |
@@ -944,15 +944,15 @@ discard block |
||
944 | 944 | |
945 | 945 | case 'lname': |
946 | 946 | $QST_values = array( |
947 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
948 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
947 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
948 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
949 | 949 | 'QST_system' => 'lname', |
950 | 950 | 'QST_type' => 'TEXT', |
951 | 951 | 'QST_required' => 1, |
952 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
952 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
953 | 953 | 'QST_order' => 2, |
954 | 954 | 'QST_admin_only' => 0, |
955 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
955 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
956 | 956 | 'QST_wp_user' => self::get_default_creator_id(), |
957 | 957 | 'QST_deleted' => 0 |
958 | 958 | ); |
@@ -960,15 +960,15 @@ discard block |
||
960 | 960 | |
961 | 961 | case 'email': |
962 | 962 | $QST_values = array( |
963 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
964 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
963 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
964 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
965 | 965 | 'QST_system' => 'email', |
966 | 966 | 'QST_type' => 'EMAIL', |
967 | 967 | 'QST_required' => 1, |
968 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
968 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
969 | 969 | 'QST_order' => 3, |
970 | 970 | 'QST_admin_only' => 0, |
971 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
971 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
972 | 972 | 'QST_wp_user' => self::get_default_creator_id(), |
973 | 973 | 'QST_deleted' => 0 |
974 | 974 | ); |
@@ -976,15 +976,15 @@ discard block |
||
976 | 976 | |
977 | 977 | case 'address': |
978 | 978 | $QST_values = array( |
979 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
980 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
979 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
980 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
981 | 981 | 'QST_system' => 'address', |
982 | 982 | 'QST_type' => 'TEXT', |
983 | 983 | 'QST_required' => 0, |
984 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
984 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
985 | 985 | 'QST_order' => 4, |
986 | 986 | 'QST_admin_only' => 0, |
987 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
987 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
988 | 988 | 'QST_wp_user' => self::get_default_creator_id(), |
989 | 989 | 'QST_deleted' => 0 |
990 | 990 | ); |
@@ -992,15 +992,15 @@ discard block |
||
992 | 992 | |
993 | 993 | case 'address2': |
994 | 994 | $QST_values = array( |
995 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
996 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
995 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
996 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
997 | 997 | 'QST_system' => 'address2', |
998 | 998 | 'QST_type' => 'TEXT', |
999 | 999 | 'QST_required' => 0, |
1000 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1000 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1001 | 1001 | 'QST_order' => 5, |
1002 | 1002 | 'QST_admin_only' => 0, |
1003 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1003 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1004 | 1004 | 'QST_wp_user' => self::get_default_creator_id(), |
1005 | 1005 | 'QST_deleted' => 0 |
1006 | 1006 | ); |
@@ -1008,27 +1008,27 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | case 'city': |
1010 | 1010 | $QST_values = array( |
1011 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1012 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1011 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1012 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1013 | 1013 | 'QST_system' => 'city', |
1014 | 1014 | 'QST_type' => 'TEXT', |
1015 | 1015 | 'QST_required' => 0, |
1016 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1016 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1017 | 1017 | 'QST_order' => 6, |
1018 | 1018 | 'QST_admin_only' => 0, |
1019 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1019 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1020 | 1020 | 'QST_wp_user' => self::get_default_creator_id(), |
1021 | 1021 | 'QST_deleted' => 0 |
1022 | 1022 | ); |
1023 | 1023 | break; |
1024 | 1024 | case 'country' : |
1025 | 1025 | $QST_values = array( |
1026 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1027 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1026 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1027 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1028 | 1028 | 'QST_system' => 'country', |
1029 | 1029 | 'QST_type' => 'COUNTRY', |
1030 | 1030 | 'QST_required' => 0, |
1031 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1031 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1032 | 1032 | 'QST_order' => 7, |
1033 | 1033 | 'QST_admin_only' => 0, |
1034 | 1034 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1038,12 +1038,12 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | case 'state': |
1040 | 1040 | $QST_values = array( |
1041 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1042 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1041 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1042 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1043 | 1043 | 'QST_system' => 'state', |
1044 | 1044 | 'QST_type' => 'STATE', |
1045 | 1045 | 'QST_required' => 0, |
1046 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1046 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1047 | 1047 | 'QST_order' => 8, |
1048 | 1048 | 'QST_admin_only' => 0, |
1049 | 1049 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1053,15 +1053,15 @@ discard block |
||
1053 | 1053 | |
1054 | 1054 | case 'zip': |
1055 | 1055 | $QST_values = array( |
1056 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1057 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1056 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1057 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1058 | 1058 | 'QST_system' => 'zip', |
1059 | 1059 | 'QST_type' => 'TEXT', |
1060 | 1060 | 'QST_required' => 0, |
1061 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1061 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1062 | 1062 | 'QST_order' => 9, |
1063 | 1063 | 'QST_admin_only' => 0, |
1064 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1064 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1065 | 1065 | 'QST_wp_user' => self::get_default_creator_id(), |
1066 | 1066 | 'QST_deleted' => 0 |
1067 | 1067 | ); |
@@ -1069,49 +1069,49 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | case 'phone': |
1071 | 1071 | $QST_values = array( |
1072 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1073 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1072 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1073 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1074 | 1074 | 'QST_system' => 'phone', |
1075 | 1075 | 'QST_type' => 'TEXT', |
1076 | 1076 | 'QST_required' => 0, |
1077 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1077 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1078 | 1078 | 'QST_order' => 10, |
1079 | 1079 | 'QST_admin_only' => 0, |
1080 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1080 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1081 | 1081 | 'QST_wp_user' => self::get_default_creator_id(), |
1082 | 1082 | 'QST_deleted' => 0 |
1083 | 1083 | ); |
1084 | 1084 | break; |
1085 | 1085 | |
1086 | 1086 | } |
1087 | - if ( ! empty( $QST_values )) { |
|
1087 | + if ( ! empty($QST_values)) { |
|
1088 | 1088 | // insert system question |
1089 | 1089 | $wpdb->insert( |
1090 | 1090 | $table_name, |
1091 | 1091 | $QST_values, |
1092 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1092 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1093 | 1093 | ); |
1094 | 1094 | $QST_ID = $wpdb->insert_id; |
1095 | 1095 | |
1096 | 1096 | // QUESTION GROUP QUESTIONS |
1097 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1097 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1098 | 1098 | $system_question_we_want = EEM_Question_Group::system_personal; |
1099 | 1099 | } else { |
1100 | 1100 | $system_question_we_want = EEM_Question_Group::system_address; |
1101 | 1101 | } |
1102 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1103 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1102 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1103 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1104 | 1104 | } else { |
1105 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1106 | - if( is_array( $id_col ) ) { |
|
1107 | - $QSG_ID = reset( $id_col ); |
|
1105 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1106 | + if (is_array($id_col)) { |
|
1107 | + $QSG_ID = reset($id_col); |
|
1108 | 1108 | } else { |
1109 | 1109 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1110 | 1110 | EE_Log::instance()->log( |
1111 | 1111 | __FILE__, |
1112 | 1112 | __FUNCTION__, |
1113 | 1113 | sprintf( |
1114 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1114 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1115 | 1115 | $QST_ID ), |
1116 | 1116 | 'error' ); |
1117 | 1117 | continue; |
@@ -1120,12 +1120,12 @@ discard block |
||
1120 | 1120 | |
1121 | 1121 | // add system questions to groups |
1122 | 1122 | $wpdb->insert( |
1123 | - \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group_question' ), |
|
1124 | - array( 'QSG_ID' => $QSG_ID, |
|
1123 | + \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1124 | + array('QSG_ID' => $QSG_ID, |
|
1125 | 1125 | 'QST_ID' => $QST_ID, |
1126 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1126 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++ |
|
1127 | 1127 | ), |
1128 | - array( '%d', '%d', '%d' ) |
|
1128 | + array('%d', '%d', '%d') |
|
1129 | 1129 | ); |
1130 | 1130 | } |
1131 | 1131 | } |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @throws \EE_Error |
1143 | 1143 | */ |
1144 | - public static function insert_default_payment_methods(){ |
|
1145 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1146 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1147 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1148 | - }else{ |
|
1144 | + public static function insert_default_payment_methods() { |
|
1145 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1146 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1147 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1148 | + } else { |
|
1149 | 1149 | EEM_Payment_Method::instance()->verify_button_urls(); |
1150 | 1150 | } |
1151 | 1151 | } |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | global $wpdb; |
1163 | 1163 | |
1164 | - if ( \EEH_Activation::getTableAnalysis()->tableExists( EEM_Status::instance()->table() ) ) { |
|
1164 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1165 | 1165 | |
1166 | 1166 | $table_name = EEM_Status::instance()->table(); |
1167 | 1167 | |
@@ -1237,33 +1237,33 @@ discard block |
||
1237 | 1237 | $folders = array( |
1238 | 1238 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1239 | 1239 | EVENT_ESPRESSO_GATEWAY_DIR, |
1240 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1241 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1242 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1240 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1241 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1242 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1243 | 1243 | ); |
1244 | - foreach ( $folders as $folder ) { |
|
1244 | + foreach ($folders as $folder) { |
|
1245 | 1245 | try { |
1246 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1247 | - @ chmod( $folder, 0755 ); |
|
1248 | - } catch( EE_Error $e ){ |
|
1246 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1247 | + @ chmod($folder, 0755); |
|
1248 | + } catch (EE_Error $e) { |
|
1249 | 1249 | EE_Error::add_error( |
1250 | 1250 | sprintf( |
1251 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1251 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1252 | 1252 | $folder, |
1253 | - '<br />' . $e->getMessage() |
|
1253 | + '<br />'.$e->getMessage() |
|
1254 | 1254 | ), |
1255 | 1255 | __FILE__, __FUNCTION__, __LINE__ |
1256 | 1256 | ); |
1257 | 1257 | //indicate we'll need to fix this later |
1258 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1258 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1259 | 1259 | return FALSE; |
1260 | 1260 | } |
1261 | 1261 | } |
1262 | 1262 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1263 | 1263 | //is disabled, there might be activation errors recorded in there |
1264 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1264 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1265 | 1265 | //remember EE's folders are all good |
1266 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1266 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1267 | 1267 | return TRUE; |
1268 | 1268 | } |
1269 | 1269 | |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | * @return boolean |
1277 | 1277 | */ |
1278 | 1278 | public static function upload_directories_incomplete() { |
1279 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1279 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1280 | 1280 | } |
1281 | 1281 | |
1282 | 1282 | |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | */ |
1294 | 1294 | public static function generate_default_message_templates() { |
1295 | 1295 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1296 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1296 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1297 | 1297 | /* |
1298 | 1298 | * This first method is taking care of ensuring any default messengers |
1299 | 1299 | * that should be made active and have templates generated are done. |
@@ -1329,22 +1329,22 @@ discard block |
||
1329 | 1329 | $active_messengers = $message_resource_manager->active_messengers(); |
1330 | 1330 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1331 | 1331 | $templates_created = false; |
1332 | - foreach ( $active_messengers as $active_messenger ) { |
|
1332 | + foreach ($active_messengers as $active_messenger) { |
|
1333 | 1333 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1334 | 1334 | $default_message_type_names_to_activate = array(); |
1335 | 1335 | // looping through each default message type reported by the messenger |
1336 | 1336 | // and setup the actual message types to activate. |
1337 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1337 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1338 | 1338 | // if already active or has already been activated before we skip |
1339 | 1339 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1340 | 1340 | // we also skip if the message type is not installed. |
1341 | 1341 | if ( |
1342 | - $message_resource_manager->has_message_type_been_activated_for_messenger( $default_message_type_name_for_messenger, $active_messenger->name ) |
|
1342 | + $message_resource_manager->has_message_type_been_activated_for_messenger($default_message_type_name_for_messenger, $active_messenger->name) |
|
1343 | 1343 | || $message_resource_manager->is_message_type_active_for_messenger( |
1344 | 1344 | $active_messenger->name, |
1345 | 1345 | $default_message_type_name_for_messenger |
1346 | 1346 | ) |
1347 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1347 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1348 | 1348 | ) { |
1349 | 1349 | continue; |
1350 | 1350 | } |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | false |
1358 | 1358 | ); |
1359 | 1359 | //activate the templates for these message types |
1360 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1360 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1361 | 1361 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1362 | 1362 | $active_messenger->name, |
1363 | 1363 | $default_message_type_names_for_messenger, |
@@ -1384,18 +1384,18 @@ discard block |
||
1384 | 1384 | EE_Message_Resource_Manager $message_resource_manager |
1385 | 1385 | ) { |
1386 | 1386 | /** @type EE_messenger[] $messengers_to_generate */ |
1387 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1387 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1388 | 1388 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1389 | 1389 | $templates_generated = false; |
1390 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1390 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1391 | 1391 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1392 | 1392 | //verify the default message types match an installed message type. |
1393 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1393 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1394 | 1394 | if ( |
1395 | - ! isset( $installed_message_types[ $name ] ) |
|
1396 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( $name, $messenger_to_generate->name ) |
|
1395 | + ! isset($installed_message_types[$name]) |
|
1396 | + || $message_resource_manager->has_message_type_been_activated_for_messenger($name, $messenger_to_generate->name) |
|
1397 | 1397 | ) { |
1398 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1398 | + unset($default_message_type_names_for_messenger[$key]); |
|
1399 | 1399 | } |
1400 | 1400 | } |
1401 | 1401 | // in previous iterations, the active_messengers option in the db |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | false |
1410 | 1410 | ); |
1411 | 1411 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1412 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1412 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1413 | 1413 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1414 | 1414 | $messenger_to_generate->name, |
1415 | 1415 | $default_message_type_names_for_messenger, |
@@ -1441,18 +1441,18 @@ discard block |
||
1441 | 1441 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1442 | 1442 | |
1443 | 1443 | $messengers_to_generate = array(); |
1444 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1444 | + foreach ($installed_messengers as $installed_messenger) { |
|
1445 | 1445 | //if installed messenger is a messenger that should be activated on install |
1446 | 1446 | //and is not already active |
1447 | 1447 | //and has never been activated |
1448 | 1448 | if ( |
1449 | 1449 | ! $installed_messenger->activate_on_install |
1450 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1451 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1450 | + || isset($active_messengers[$installed_messenger->name]) |
|
1451 | + || isset($has_activated[$installed_messenger->name]) |
|
1452 | 1452 | ) { |
1453 | 1453 | continue; |
1454 | 1454 | } |
1455 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1455 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1456 | 1456 | } |
1457 | 1457 | return $messengers_to_generate; |
1458 | 1458 | } |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | */ |
1478 | 1478 | public static function validate_messages_system() { |
1479 | 1479 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1480 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1480 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1481 | 1481 | $message_resource_manager->validate_active_message_types_are_installed(); |
1482 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1482 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | |
@@ -1492,12 +1492,12 @@ discard block |
||
1492 | 1492 | * @static |
1493 | 1493 | * @return void |
1494 | 1494 | */ |
1495 | - public static function create_no_ticket_prices_array(){ |
|
1495 | + public static function create_no_ticket_prices_array() { |
|
1496 | 1496 | // this creates an array for tracking events that have no active ticket prices created |
1497 | 1497 | // this allows us to warn admins of the situation so that it can be corrected |
1498 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1499 | - if ( ! $espresso_no_ticket_prices ) { |
|
1500 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1498 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1499 | + if ( ! $espresso_no_ticket_prices) { |
|
1500 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1501 | 1501 | } |
1502 | 1502 | } |
1503 | 1503 | |
@@ -1522,24 +1522,24 @@ discard block |
||
1522 | 1522 | * @global wpdb $wpdb |
1523 | 1523 | * @throws \EE_Error |
1524 | 1524 | */ |
1525 | - public static function delete_all_espresso_cpt_data(){ |
|
1525 | + public static function delete_all_espresso_cpt_data() { |
|
1526 | 1526 | global $wpdb; |
1527 | 1527 | //get all the CPT post_types |
1528 | 1528 | $ee_post_types = array(); |
1529 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1530 | - if ( method_exists( $model_name, 'instance' )) { |
|
1531 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1532 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1533 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1529 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1530 | + if (method_exists($model_name, 'instance')) { |
|
1531 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1532 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1533 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | //get all our CPTs |
1538 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1538 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1539 | 1539 | $cpt_ids = $wpdb->get_col($query); |
1540 | 1540 | //delete each post meta and term relations too |
1541 | - foreach($cpt_ids as $post_id){ |
|
1542 | - wp_delete_post($post_id,true); |
|
1541 | + foreach ($cpt_ids as $post_id) { |
|
1542 | + wp_delete_post($post_id, true); |
|
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | |
@@ -1551,12 +1551,12 @@ discard block |
||
1551 | 1551 | public static function drop_espresso_tables() { |
1552 | 1552 | $tables = array(); |
1553 | 1553 | // load registry |
1554 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1555 | - if ( method_exists( $model_name, 'instance' )) { |
|
1556 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1557 | - if ( $model_obj instanceof EEM_Base ) { |
|
1558 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1559 | - if ( strpos( $table->get_table_name(), 'esp_' ) |
|
1554 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1555 | + if (method_exists($model_name, 'instance')) { |
|
1556 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1557 | + if ($model_obj instanceof EEM_Base) { |
|
1558 | + foreach ($model_obj->get_tables() as $table) { |
|
1559 | + if (strpos($table->get_table_name(), 'esp_') |
|
1560 | 1560 | && |
1561 | 1561 | ( |
1562 | 1562 | is_main_site()//main site? nuke them all |
@@ -1579,10 +1579,10 @@ discard block |
||
1579 | 1579 | 'esp_promotion_rule', |
1580 | 1580 | 'esp_rule' |
1581 | 1581 | ); |
1582 | - foreach( $tables_without_models as $table ){ |
|
1582 | + foreach ($tables_without_models as $table) { |
|
1583 | 1583 | $tables[] = $table; |
1584 | 1584 | } |
1585 | - return \EEH_Activation::getTableManager()->dropTables( $tables ); |
|
1585 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1586 | 1586 | } |
1587 | 1587 | |
1588 | 1588 | /** |
@@ -1594,8 +1594,8 @@ discard block |
||
1594 | 1594 | * @param array $table_names |
1595 | 1595 | * @return array of table names which we deleted |
1596 | 1596 | */ |
1597 | - public static function drop_tables( $table_names ) { |
|
1598 | - return \EEH_Activation::getTableManager()->dropTables( $table_names ); |
|
1597 | + public static function drop_tables($table_names) { |
|
1598 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1599 | 1599 | } |
1600 | 1600 | /** |
1601 | 1601 | * plugin_uninstall |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | * @param bool $remove_all |
1606 | 1606 | * @return void |
1607 | 1607 | */ |
1608 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1608 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1609 | 1609 | global $wpdb; |
1610 | 1610 | self::drop_espresso_tables(); |
1611 | 1611 | |
@@ -1643,50 +1643,50 @@ discard block |
||
1643 | 1643 | 'ee_job_parameters_' => false, |
1644 | 1644 | 'ee_upload_directories_incomplete' => true, |
1645 | 1645 | ); |
1646 | - if( is_main_site() ) { |
|
1647 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1646 | + if (is_main_site()) { |
|
1647 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | $undeleted_options = array(); |
1651 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1651 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1652 | 1652 | |
1653 | - if( $no_wildcard ){ |
|
1654 | - if( ! delete_option( $option_name ) ){ |
|
1653 | + if ($no_wildcard) { |
|
1654 | + if ( ! delete_option($option_name)) { |
|
1655 | 1655 | $undeleted_options[] = $option_name; |
1656 | 1656 | } |
1657 | - }else{ |
|
1658 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1659 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1660 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1657 | + } else { |
|
1658 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1659 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1660 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1661 | 1661 | $undeleted_options[] = $option_name_from_wildcard; |
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | } |
1666 | 1666 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1667 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1667 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1668 | 1668 | |
1669 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1669 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1670 | 1670 | $db_update_sans_ee4 = array(); |
1671 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1672 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
1671 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1672 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1673 | 1673 | $db_update_sans_ee4[$version] = $times_activated; |
1674 | 1674 | } |
1675 | 1675 | } |
1676 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1676 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | $errors = ''; |
1680 | - if ( ! empty( $undeleted_options )) { |
|
1680 | + if ( ! empty($undeleted_options)) { |
|
1681 | 1681 | $errors .= sprintf( |
1682 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1682 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1683 | 1683 | '<br/>', |
1684 | - implode( ',<br/>', $undeleted_options ) |
|
1684 | + implode(',<br/>', $undeleted_options) |
|
1685 | 1685 | ); |
1686 | 1686 | |
1687 | 1687 | } |
1688 | - if ( ! empty( $errors ) ) { |
|
1689 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1688 | + if ( ! empty($errors)) { |
|
1689 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1690 | 1690 | } |
1691 | 1691 | } |
1692 | 1692 | |
@@ -1696,10 +1696,10 @@ discard block |
||
1696 | 1696 | */ |
1697 | 1697 | public static function last_wpdb_error_code() { |
1698 | 1698 | global $wpdb; |
1699 | - if( $wpdb->use_mysqli ) { |
|
1700 | - return mysqli_errno( $wpdb->dbh ); |
|
1699 | + if ($wpdb->use_mysqli) { |
|
1700 | + return mysqli_errno($wpdb->dbh); |
|
1701 | 1701 | } else { |
1702 | - return mysql_errno( $wpdb->dbh ); |
|
1702 | + return mysql_errno($wpdb->dbh); |
|
1703 | 1703 | } |
1704 | 1704 | } |
1705 | 1705 | |
@@ -1710,14 +1710,14 @@ discard block |
||
1710 | 1710 | * @param string $table_name with or without $wpdb->prefix |
1711 | 1711 | * @return boolean |
1712 | 1712 | */ |
1713 | - public static function table_exists( $table_name ){ |
|
1714 | - return \EEH_Activation::getTableAnalysis()->tableExists( $table_name ); |
|
1713 | + public static function table_exists($table_name) { |
|
1714 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | /** |
1718 | 1718 | * Resets the cache on EEH_Activation |
1719 | 1719 | */ |
1720 | - public static function reset(){ |
|
1720 | + public static function reset() { |
|
1721 | 1721 | self::$_default_creator_id = NULL; |
1722 | 1722 | self::$_initialized_db_content_already_in_this_request = false; |
1723 | 1723 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -17,818 +17,818 @@ discard block |
||
17 | 17 | class EED_Core_Rest_Api extends \EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - const ee_api_namespace = 'ee/v'; |
|
20 | + const ee_api_namespace = 'ee/v'; |
|
21 | 21 | |
22 | - const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/'; |
|
22 | + const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/'; |
|
23 | 23 | |
24 | - const saved_routes_option_names = 'ee_core_routes'; |
|
24 | + const saved_routes_option_names = 'ee_core_routes'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * string used in _links response bodies to make them globally unique. |
|
28 | - * |
|
29 | - * @see http://v2.wp-api.org/extending/linking/ |
|
30 | - */ |
|
31 | - const ee_api_link_namespace = 'https://api.eventespresso.com/'; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var Calculated_Model_Fields |
|
35 | - */ |
|
36 | - protected static $_field_calculator = null; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return EED_Core_Rest_Api |
|
42 | - */ |
|
43 | - public static function instance() |
|
44 | - { |
|
45 | - self::$_field_calculator = new Calculated_Model_Fields(); |
|
46 | - return parent::get_instance(__CLASS__); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public static function set_hooks() |
|
58 | - { |
|
59 | - self::set_hooks_both(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public static function set_hooks_admin() |
|
71 | - { |
|
72 | - self::set_hooks_both(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - public static function set_hooks_both() |
|
78 | - { |
|
79 | - add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
80 | - add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
81 | - add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
82 | - add_filter('rest_index', |
|
83 | - array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
84 | - EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * sets up hooks which only need to be included as part of REST API requests; |
|
91 | - * other requests like to the frontend or admin etc don't need them |
|
92 | - */ |
|
93 | - public static function set_hooks_rest_api() |
|
94 | - { |
|
95 | - //set hooks which account for changes made to the API |
|
96 | - EED_Core_Rest_Api::_set_hooks_for_changes(); |
|
97 | - EED_Core_Rest_Api::maybe_notify_of_basic_auth_removal(); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * public wrapper of _set_hooks_for_changes. |
|
104 | - * Loads all the hooks which make requests to old versions of the API |
|
105 | - * appear the same as they always did |
|
106 | - */ |
|
107 | - public static function set_hooks_for_changes() |
|
108 | - { |
|
109 | - self::_set_hooks_for_changes(); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * If the user appears to be using WP API basic auth, tell them (via a persistent |
|
116 | - * admin notice and an email) that we're going to remove it soon, so they should |
|
117 | - * replace it with application passwords. |
|
118 | - */ |
|
119 | - public static function maybe_notify_of_basic_auth_removal() |
|
120 | - { |
|
121 | - if ( |
|
122 | - apply_filters( |
|
123 | - 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
|
124 | - ! isset($_SERVER['PHP_AUTH_USER']) |
|
125 | - && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
126 | - ) |
|
127 | - ) { |
|
128 | - //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
|
129 | - return; |
|
130 | - } |
|
131 | - //ok they're using the WP API with Basic Auth |
|
132 | - $message = sprintf( |
|
133 | - __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', |
|
134 | - 'event_espresso'), |
|
135 | - '<a href="https://wordpress.org/plugins/application-passwords/">', |
|
136 | - '</a>', |
|
137 | - '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
|
138 | - '<br/>' |
|
139 | - ); |
|
140 | - EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
141 | - if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
142 | - add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
143 | - //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
|
144 | - add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
145 | - //and send the message to the site admin too |
|
146 | - wp_mail(get_option('admin_email'), |
|
147 | - __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
148 | - remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * Loads all the hooks which make requests to old versions of the API |
|
156 | - * appear the same as they always did |
|
157 | - */ |
|
158 | - protected static function _set_hooks_for_changes() |
|
159 | - { |
|
160 | - $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
161 | - foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
162 | - //ignore the base parent class |
|
163 | - if ($classname_in_namespace === 'Changes_In_Base') { |
|
164 | - continue; |
|
165 | - } |
|
166 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
167 | - if (class_exists($full_classname)) { |
|
168 | - $instance_of_class = new $full_classname; |
|
169 | - if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
170 | - $instance_of_class->set_hooks(); |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * Filters the WP routes to add our EE-related ones. This takes a bit of time |
|
180 | - * so we actually prefer to only do it when an EE plugin is activated or upgraded |
|
181 | - */ |
|
182 | - public static function register_routes() |
|
183 | - { |
|
184 | - foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
185 | - foreach ($relative_urls as $endpoint => $routes) { |
|
186 | - foreach ($routes as $route) { |
|
187 | - register_rest_route( |
|
188 | - $namespace, |
|
189 | - $endpoint, |
|
190 | - array( |
|
191 | - 'callback' => $route['callback'], |
|
192 | - 'methods' => $route['methods'], |
|
193 | - 'args' => isset($route['args']) ? $route['args'] : array(), |
|
194 | - ) |
|
195 | - ); |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Checks if there was a version change or something that merits invalidating the cached |
|
205 | - * route data. If so, invalidates the cached route data so that it gets refreshed |
|
206 | - * next time the WP API is used |
|
207 | - */ |
|
208 | - public static function invalidate_cached_route_data_on_version_change() |
|
209 | - { |
|
210 | - if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
211 | - EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
212 | - } |
|
213 | - foreach (EE_Registry::instance()->addons as $addon) { |
|
214 | - if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
215 | - EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * Removes the cached route data so it will get refreshed next time the WP API is used |
|
224 | - */ |
|
225 | - public static function invalidate_cached_route_data() |
|
226 | - { |
|
227 | - //delete the saved EE REST API routes |
|
228 | - foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
229 | - delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Gets the EE route data |
|
237 | - * |
|
238 | - * @return array top-level key is the namespace, next-level key is the route and its value is array{ |
|
239 | - * @type string|array $callback |
|
240 | - * @type string $methods |
|
241 | - * @type boolean $hidden_endpoint |
|
242 | - * } |
|
243 | - */ |
|
244 | - public static function get_ee_route_data() |
|
245 | - { |
|
246 | - $ee_routes = array(); |
|
247 | - foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
248 | - $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
249 | - $hidden_endpoints); |
|
250 | - } |
|
251 | - return $ee_routes; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Gets the EE route data from the wp options if it exists already, |
|
258 | - * otherwise re-generates it and saves it to the option |
|
259 | - * |
|
260 | - * @param string $version |
|
261 | - * @param boolean $hidden_endpoints |
|
262 | - * @return array |
|
263 | - */ |
|
264 | - protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
265 | - { |
|
266 | - $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
267 | - if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
268 | - $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
269 | - } |
|
270 | - return $ee_routes; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Saves the EE REST API route data to a wp option and returns it |
|
277 | - * |
|
278 | - * @param string $version |
|
279 | - * @param boolean $hidden_endpoints |
|
280 | - * @return mixed|null|void |
|
281 | - */ |
|
282 | - protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
283 | - { |
|
284 | - $instance = self::instance(); |
|
285 | - $routes = apply_filters( |
|
286 | - 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
|
287 | - array_replace_recursive( |
|
288 | - $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
289 | - $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
290 | - $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
291 | - $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
292 | - ) |
|
293 | - ); |
|
294 | - $option_name = self::saved_routes_option_names . $version; |
|
295 | - if (get_option($option_name)) { |
|
296 | - update_option($option_name, $routes, true); |
|
297 | - } else { |
|
298 | - add_option($option_name, $routes, null, 'no'); |
|
299 | - } |
|
300 | - return $routes; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * Calculates all the EE routes and saves it to a wordpress option so we don't |
|
307 | - * need to calculate it on every request |
|
308 | - * |
|
309 | - * @deprecated since version 4.9.1 |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - public static function save_ee_routes() |
|
313 | - { |
|
314 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
315 | - $instance = self::instance(); |
|
316 | - $routes = apply_filters( |
|
317 | - 'EED_Core_Rest_Api__save_ee_routes__routes', |
|
318 | - array_replace_recursive( |
|
319 | - $instance->_register_config_routes(), |
|
320 | - $instance->_register_meta_routes(), |
|
321 | - $instance->_register_model_routes(), |
|
322 | - $instance->_register_rpc_routes() |
|
323 | - ) |
|
324 | - ); |
|
325 | - update_option(self::saved_routes_option_names, $routes, true); |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * Gets all the route information relating to EE models |
|
333 | - * |
|
334 | - * @return array @see get_ee_route_data |
|
335 | - * @deprecated since version 4.9.1 |
|
336 | - */ |
|
337 | - protected function _register_model_routes() |
|
338 | - { |
|
339 | - $model_routes = array(); |
|
340 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
341 | - $model_routes[EED_Core_Rest_Api::ee_api_namespace |
|
342 | - . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
343 | - } |
|
344 | - return $model_routes; |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * Gets the route data for EE models in the specified version |
|
351 | - * |
|
352 | - * @param string $version |
|
353 | - * @param boolean $hidden_endpoint |
|
354 | - * @return array |
|
355 | - */ |
|
356 | - protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) |
|
357 | - { |
|
358 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
359 | - $models_to_register = apply_filters( |
|
360 | - 'FHEE__EED_Core_REST_API___register_model_routes', |
|
361 | - $model_version_info->models_for_requested_version() |
|
362 | - ); |
|
363 | - //let's not bother having endpoints for extra metas |
|
364 | - unset($models_to_register['Extra_Meta']); |
|
365 | - unset($models_to_register['Extra_Join']); |
|
366 | - $model_routes = array(); |
|
367 | - foreach ($models_to_register as $model_name => $model_classname) { |
|
368 | - $model = \EE_Registry::instance()->load_model($model_name); |
|
369 | - //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
|
370 | - $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
371 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
372 | - $model_routes[$plural_model_route] = array( |
|
373 | - array( |
|
374 | - 'callback' => array( |
|
375 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
376 | - 'handle_request_get_all', |
|
377 | - ), |
|
378 | - 'methods' => WP_REST_Server::READABLE, |
|
379 | - 'hidden_endpoint' => $hidden_endpoint, |
|
380 | - 'args' => $this->_get_read_query_params($model, $version), |
|
381 | - '_links' => array( |
|
382 | - 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
383 | - ), |
|
384 | - ), |
|
385 | - // array( |
|
386 | - // 'callback' => array( |
|
387 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
388 | - // 'handle_request_create_one' ), |
|
389 | - // 'methods' => WP_REST_Server::CREATABLE, |
|
390 | - // 'hidden_endpoint' => $hidden_endpoint |
|
391 | - // ) |
|
392 | - ); |
|
393 | - $model_routes[$singular_model_route] = array( |
|
394 | - array( |
|
395 | - 'callback' => array( |
|
396 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
397 | - 'handle_request_get_one', |
|
398 | - ), |
|
399 | - 'methods' => WP_REST_Server::READABLE, |
|
400 | - 'hidden_endpoint' => $hidden_endpoint, |
|
401 | - 'args' => $this->_get_response_selection_query_params($model, $version), |
|
402 | - ), |
|
403 | - // array( |
|
404 | - // 'callback' => array( |
|
405 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
406 | - // 'handle_request_edit_one' ), |
|
407 | - // 'methods' => WP_REST_Server::EDITABLE, |
|
408 | - // 'hidden_endpoint' => $hidden_endpoint |
|
409 | - // ), |
|
410 | - ); |
|
411 | - //@todo: also handle DELETE for a single item |
|
412 | - foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
413 | - $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
|
414 | - $relation_name, |
|
415 | - $relation_obj |
|
416 | - ); |
|
417 | - $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
418 | - array( |
|
419 | - 'callback' => array( |
|
420 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
421 | - 'handle_request_get_related', |
|
422 | - ), |
|
423 | - 'methods' => WP_REST_Server::READABLE, |
|
424 | - 'hidden_endpoint' => $hidden_endpoint, |
|
425 | - 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
426 | - ), |
|
427 | - // array( |
|
428 | - // 'callback' => array( |
|
429 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
430 | - // 'handle_request_create_or_update_related' ), |
|
431 | - // 'methods' => WP_REST_Server::EDITABLE, |
|
432 | - // 'hidden_endpoint' => $hidden_endpoint |
|
433 | - // ) |
|
434 | - ); |
|
435 | - //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish) |
|
436 | - } |
|
437 | - } |
|
438 | - return $model_routes; |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * Adds all the RPC-style routes (remote procedure call-like routes, ie |
|
445 | - * routes that don't conform to the traditional REST CRUD-style). |
|
446 | - * |
|
447 | - * @deprecated since 4.9.1 |
|
448 | - */ |
|
449 | - protected function _register_rpc_routes() |
|
450 | - { |
|
451 | - $routes = array(); |
|
452 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
453 | - $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | - $hidden_endpoint); |
|
455 | - } |
|
456 | - return $routes; |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * @param string $version |
|
463 | - * @param boolean $hidden_endpoint |
|
464 | - * @return array |
|
465 | - */ |
|
466 | - protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) |
|
467 | - { |
|
468 | - $this_versions_routes = array(); |
|
469 | - //checkin endpoint |
|
470 | - $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
471 | - array( |
|
472 | - 'callback' => array( |
|
473 | - 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
|
474 | - 'handle_request_toggle_checkin', |
|
475 | - ), |
|
476 | - 'methods' => WP_REST_Server::CREATABLE, |
|
477 | - 'hidden_endpoint' => $hidden_endpoint, |
|
478 | - 'args' => array( |
|
479 | - 'force' => array( |
|
480 | - 'required' => false, |
|
481 | - 'default' => false, |
|
482 | - 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', |
|
483 | - 'event_espresso'), |
|
484 | - ), |
|
485 | - ), |
|
486 | - ), |
|
487 | - ); |
|
488 | - return apply_filters( |
|
489 | - 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
490 | - $this_versions_routes, |
|
491 | - $version, |
|
492 | - $hidden_endpoint |
|
493 | - ); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * Gets the query params that can be used when request one or many |
|
500 | - * |
|
501 | - * @param EEM_Base $model |
|
502 | - * @param string $version |
|
503 | - * @return array |
|
504 | - */ |
|
505 | - protected function _get_response_selection_query_params(\EEM_Base $model, $version) |
|
506 | - { |
|
507 | - return apply_filters( |
|
508 | - 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
|
509 | - array( |
|
510 | - 'include' => array( |
|
511 | - 'required' => false, |
|
512 | - 'default' => '*', |
|
513 | - ), |
|
514 | - 'calculate' => array( |
|
515 | - 'required' => false, |
|
516 | - 'default' => '', |
|
517 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model), |
|
518 | - ), |
|
519 | - ), |
|
520 | - $model, |
|
521 | - $version |
|
522 | - ); |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - |
|
527 | - /** |
|
528 | - * Gets info about reading query params that are acceptable |
|
529 | - * |
|
530 | - * @param \EEM_Base $model eg 'Event' or 'Venue' |
|
531 | - * @param string $version |
|
532 | - * @return array describing the args acceptable when querying this model |
|
533 | - * @throws \EE_Error |
|
534 | - */ |
|
535 | - protected function _get_read_query_params(\EEM_Base $model, $version) |
|
536 | - { |
|
537 | - $default_orderby = array(); |
|
538 | - foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
539 | - $default_orderby[$key_field->get_name()] = 'ASC'; |
|
540 | - } |
|
541 | - return array_merge( |
|
542 | - $this->_get_response_selection_query_params($model, $version), |
|
543 | - array( |
|
544 | - 'where' => array( |
|
545 | - 'required' => false, |
|
546 | - 'default' => array(), |
|
547 | - ), |
|
548 | - 'limit' => array( |
|
549 | - 'required' => false, |
|
550 | - 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
|
551 | - ), |
|
552 | - 'order_by' => array( |
|
553 | - 'required' => false, |
|
554 | - 'default' => $default_orderby, |
|
555 | - ), |
|
556 | - 'group_by' => array( |
|
557 | - 'required' => false, |
|
558 | - 'default' => null, |
|
559 | - ), |
|
560 | - 'having' => array( |
|
561 | - 'required' => false, |
|
562 | - 'default' => null, |
|
563 | - ), |
|
564 | - 'caps' => array( |
|
565 | - 'required' => false, |
|
566 | - 'default' => EEM_Base::caps_read, |
|
567 | - ), |
|
568 | - ) |
|
569 | - ); |
|
570 | - } |
|
571 | - |
|
572 | - |
|
573 | - |
|
574 | - /** |
|
575 | - * Gets routes for the config |
|
576 | - * |
|
577 | - * @return array @see _register_model_routes |
|
578 | - * @deprecated since version 4.9.1 |
|
579 | - */ |
|
580 | - protected function _register_config_routes() |
|
581 | - { |
|
582 | - $config_routes = array(); |
|
583 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
584 | - $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
585 | - $hidden_endpoint); |
|
586 | - } |
|
587 | - return $config_routes; |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * Gets routes for the config for the specified version |
|
594 | - * |
|
595 | - * @param string $version |
|
596 | - * @param boolean $hidden_endpoint |
|
597 | - * @return array |
|
598 | - */ |
|
599 | - protected function _get_config_route_data_for_version($version, $hidden_endpoint) |
|
600 | - { |
|
601 | - return array( |
|
602 | - 'config' => array( |
|
603 | - array( |
|
604 | - 'callback' => array( |
|
605 | - 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
606 | - 'handle_request', |
|
607 | - ), |
|
608 | - 'methods' => WP_REST_Server::READABLE, |
|
609 | - 'hidden_endpoint' => $hidden_endpoint, |
|
610 | - ), |
|
611 | - ), |
|
612 | - 'site_info' => array( |
|
613 | - array( |
|
614 | - 'callback' => array( |
|
615 | - 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
616 | - 'handle_request_site_info', |
|
617 | - ), |
|
618 | - 'methods' => WP_REST_Server::READABLE, |
|
619 | - 'hidden_endpoint' => $hidden_endpoint, |
|
620 | - ), |
|
621 | - ), |
|
622 | - ); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * Gets the meta info routes |
|
629 | - * |
|
630 | - * @return array @see _register_model_routes |
|
631 | - * @deprecated since version 4.9.1 |
|
632 | - */ |
|
633 | - protected function _register_meta_routes() |
|
634 | - { |
|
635 | - $meta_routes = array(); |
|
636 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
637 | - $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
638 | - $hidden_endpoint); |
|
639 | - } |
|
640 | - return $meta_routes; |
|
641 | - } |
|
642 | - |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * @param string $version |
|
647 | - * @param boolean $hidden_endpoint |
|
648 | - * @return array |
|
649 | - */ |
|
650 | - protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) |
|
651 | - { |
|
652 | - return array( |
|
653 | - 'resources' => array( |
|
654 | - array( |
|
655 | - 'callback' => array( |
|
656 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
|
657 | - 'handle_request_models_meta', |
|
658 | - ), |
|
659 | - 'methods' => WP_REST_Server::READABLE, |
|
660 | - 'hidden_endpoint' => $hidden_endpoint, |
|
661 | - ), |
|
662 | - ), |
|
663 | - ); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * Tries to hide old 4.6 endpoints from the |
|
670 | - * |
|
671 | - * @param array $route_data |
|
672 | - * @return array |
|
673 | - */ |
|
674 | - public static function hide_old_endpoints($route_data) |
|
675 | - { |
|
676 | - //allow API clients to override which endpoints get hidden, in case |
|
677 | - //they want to discover particular endpoints |
|
678 | - //also, we don't have access to the request so we have to just grab it from the superglobal |
|
679 | - $force_show_ee_namespace = ltrim( |
|
680 | - EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
681 | - '/' |
|
682 | - ); |
|
683 | - foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
684 | - foreach ($relative_urls as $endpoint => $routes) { |
|
685 | - foreach ($routes as $route) { |
|
686 | - //by default, hide "hidden_endpoint"s, unless the request indicates |
|
687 | - //to $force_show_ee_namespace, in which case only show that one |
|
688 | - //namespace's endpoints (and hide all others) |
|
689 | - if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
690 | - || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
|
691 | - ) { |
|
692 | - $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
693 | - unset($route_data[$full_route]); |
|
694 | - } |
|
695 | - } |
|
696 | - } |
|
697 | - } |
|
698 | - return $route_data; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * Returns an array describing which versions of core support serving requests for. |
|
705 | - * Keys are core versions' major and minor version, and values are the |
|
706 | - * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like |
|
707 | - * data by just removing a few models and fields from the responses. However, 4.15 might remove |
|
708 | - * the answers table entirely, in which case it would be very difficult for |
|
709 | - * it to serve 4.6-style responses. |
|
710 | - * Versions of core that are missing from this array are unknowns. |
|
711 | - * previous ver |
|
712 | - * |
|
713 | - * @return array |
|
714 | - */ |
|
715 | - public static function version_compatibilities() |
|
716 | - { |
|
717 | - return apply_filters( |
|
718 | - 'FHEE__EED_Core_REST_API__version_compatibilities', |
|
719 | - array( |
|
720 | - '4.8.29' => '4.8.29', |
|
721 | - '4.8.33' => '4.8.29', |
|
722 | - '4.8.34' => '4.8.29', |
|
723 | - '4.8.36' => '4.8.29', |
|
724 | - ) |
|
725 | - ); |
|
726 | - } |
|
727 | - |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * Gets the latest API version served. Eg if there |
|
732 | - * are two versions served of the API, 4.8.29 and 4.8.32, and |
|
733 | - * we are on core version 4.8.34, it will return the string "4.8.32" |
|
734 | - * |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public static function latest_rest_api_version() |
|
738 | - { |
|
739 | - $versions_served = \EED_Core_Rest_Api::versions_served(); |
|
740 | - $versions_served_keys = array_keys($versions_served); |
|
741 | - return end($versions_served_keys); |
|
742 | - } |
|
743 | - |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of |
|
748 | - * EE the API can serve requests for. Eg, if we are on 4.15 of core, and |
|
749 | - * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ). |
|
750 | - * We also indicate whether or not this version should be put in the index or not |
|
751 | - * |
|
752 | - * @return array keys are API version numbers (just major and minor numbers), and values |
|
753 | - * are whether or not they should be hidden |
|
754 | - */ |
|
755 | - public static function versions_served() |
|
756 | - { |
|
757 | - $versions_served = array(); |
|
758 | - $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
|
759 | - $lowest_compatible_version = end($possibly_served_versions); |
|
760 | - reset($possibly_served_versions); |
|
761 | - $versions_served_historically = array_keys($possibly_served_versions); |
|
762 | - $latest_version = end($versions_served_historically); |
|
763 | - reset($versions_served_historically); |
|
764 | - //for each version of core we have ever served: |
|
765 | - foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
766 | - //if it's not above the current core version, and it's compatible with the current version of core |
|
767 | - if ($key_versioned_endpoint == $latest_version) { |
|
768 | - //don't hide the latest version in the index |
|
769 | - $versions_served[$key_versioned_endpoint] = false; |
|
770 | - } else if ( |
|
771 | - $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
|
772 | - && $key_versioned_endpoint >= $lowest_compatible_version |
|
773 | - ) { |
|
774 | - //include, but hide, previous versions which are still supported |
|
775 | - $versions_served[$key_versioned_endpoint] = true; |
|
776 | - } elseif ( |
|
777 | - apply_filters( |
|
778 | - 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
|
779 | - false, |
|
780 | - $possibly_served_versions |
|
781 | - ) |
|
782 | - ) { |
|
783 | - //if a version is no longer supported, don't include it in index or list of versions served |
|
784 | - $versions_served[$key_versioned_endpoint] = true; |
|
785 | - } |
|
786 | - } |
|
787 | - return $versions_served; |
|
788 | - } |
|
789 | - |
|
790 | - |
|
791 | - |
|
792 | - /** |
|
793 | - * Gets the major and minor version of EE core's version string |
|
794 | - * |
|
795 | - * @return string |
|
796 | - */ |
|
797 | - public static function core_version() |
|
798 | - { |
|
799 | - return apply_filters('FHEE__EED_Core_REST_API__core_version', |
|
800 | - implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
801 | - } |
|
802 | - |
|
803 | - |
|
804 | - |
|
805 | - /** |
|
806 | - * Gets the default limit that should be used when querying for resources |
|
807 | - * |
|
808 | - * @return int |
|
809 | - */ |
|
810 | - public static function get_default_query_limit() |
|
811 | - { |
|
812 | - //we actually don't use a const because we want folks to always use |
|
813 | - //this method, not the const directly |
|
814 | - return apply_filters( |
|
815 | - 'FHEE__EED_Core_Rest_Api__get_default_query_limit', |
|
816 | - 50 |
|
817 | - ); |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - |
|
822 | - /** |
|
823 | - * run - initial module setup |
|
824 | - * |
|
825 | - * @access public |
|
826 | - * @param WP $WP |
|
827 | - * @return void |
|
828 | - */ |
|
829 | - public function run($WP) |
|
830 | - { |
|
831 | - } |
|
26 | + /** |
|
27 | + * string used in _links response bodies to make them globally unique. |
|
28 | + * |
|
29 | + * @see http://v2.wp-api.org/extending/linking/ |
|
30 | + */ |
|
31 | + const ee_api_link_namespace = 'https://api.eventespresso.com/'; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var Calculated_Model_Fields |
|
35 | + */ |
|
36 | + protected static $_field_calculator = null; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return EED_Core_Rest_Api |
|
42 | + */ |
|
43 | + public static function instance() |
|
44 | + { |
|
45 | + self::$_field_calculator = new Calculated_Model_Fields(); |
|
46 | + return parent::get_instance(__CLASS__); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public static function set_hooks() |
|
58 | + { |
|
59 | + self::set_hooks_both(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public static function set_hooks_admin() |
|
71 | + { |
|
72 | + self::set_hooks_both(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + public static function set_hooks_both() |
|
78 | + { |
|
79 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
80 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
81 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
82 | + add_filter('rest_index', |
|
83 | + array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
84 | + EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * sets up hooks which only need to be included as part of REST API requests; |
|
91 | + * other requests like to the frontend or admin etc don't need them |
|
92 | + */ |
|
93 | + public static function set_hooks_rest_api() |
|
94 | + { |
|
95 | + //set hooks which account for changes made to the API |
|
96 | + EED_Core_Rest_Api::_set_hooks_for_changes(); |
|
97 | + EED_Core_Rest_Api::maybe_notify_of_basic_auth_removal(); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * public wrapper of _set_hooks_for_changes. |
|
104 | + * Loads all the hooks which make requests to old versions of the API |
|
105 | + * appear the same as they always did |
|
106 | + */ |
|
107 | + public static function set_hooks_for_changes() |
|
108 | + { |
|
109 | + self::_set_hooks_for_changes(); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * If the user appears to be using WP API basic auth, tell them (via a persistent |
|
116 | + * admin notice and an email) that we're going to remove it soon, so they should |
|
117 | + * replace it with application passwords. |
|
118 | + */ |
|
119 | + public static function maybe_notify_of_basic_auth_removal() |
|
120 | + { |
|
121 | + if ( |
|
122 | + apply_filters( |
|
123 | + 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
|
124 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
125 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
126 | + ) |
|
127 | + ) { |
|
128 | + //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
|
129 | + return; |
|
130 | + } |
|
131 | + //ok they're using the WP API with Basic Auth |
|
132 | + $message = sprintf( |
|
133 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', |
|
134 | + 'event_espresso'), |
|
135 | + '<a href="https://wordpress.org/plugins/application-passwords/">', |
|
136 | + '</a>', |
|
137 | + '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
|
138 | + '<br/>' |
|
139 | + ); |
|
140 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
141 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
142 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
143 | + //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
|
144 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
145 | + //and send the message to the site admin too |
|
146 | + wp_mail(get_option('admin_email'), |
|
147 | + __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
148 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * Loads all the hooks which make requests to old versions of the API |
|
156 | + * appear the same as they always did |
|
157 | + */ |
|
158 | + protected static function _set_hooks_for_changes() |
|
159 | + { |
|
160 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
161 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
162 | + //ignore the base parent class |
|
163 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
164 | + continue; |
|
165 | + } |
|
166 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
167 | + if (class_exists($full_classname)) { |
|
168 | + $instance_of_class = new $full_classname; |
|
169 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
170 | + $instance_of_class->set_hooks(); |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * Filters the WP routes to add our EE-related ones. This takes a bit of time |
|
180 | + * so we actually prefer to only do it when an EE plugin is activated or upgraded |
|
181 | + */ |
|
182 | + public static function register_routes() |
|
183 | + { |
|
184 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
185 | + foreach ($relative_urls as $endpoint => $routes) { |
|
186 | + foreach ($routes as $route) { |
|
187 | + register_rest_route( |
|
188 | + $namespace, |
|
189 | + $endpoint, |
|
190 | + array( |
|
191 | + 'callback' => $route['callback'], |
|
192 | + 'methods' => $route['methods'], |
|
193 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
194 | + ) |
|
195 | + ); |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Checks if there was a version change or something that merits invalidating the cached |
|
205 | + * route data. If so, invalidates the cached route data so that it gets refreshed |
|
206 | + * next time the WP API is used |
|
207 | + */ |
|
208 | + public static function invalidate_cached_route_data_on_version_change() |
|
209 | + { |
|
210 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
211 | + EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
212 | + } |
|
213 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
214 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
215 | + EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * Removes the cached route data so it will get refreshed next time the WP API is used |
|
224 | + */ |
|
225 | + public static function invalidate_cached_route_data() |
|
226 | + { |
|
227 | + //delete the saved EE REST API routes |
|
228 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
229 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Gets the EE route data |
|
237 | + * |
|
238 | + * @return array top-level key is the namespace, next-level key is the route and its value is array{ |
|
239 | + * @type string|array $callback |
|
240 | + * @type string $methods |
|
241 | + * @type boolean $hidden_endpoint |
|
242 | + * } |
|
243 | + */ |
|
244 | + public static function get_ee_route_data() |
|
245 | + { |
|
246 | + $ee_routes = array(); |
|
247 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
248 | + $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
249 | + $hidden_endpoints); |
|
250 | + } |
|
251 | + return $ee_routes; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Gets the EE route data from the wp options if it exists already, |
|
258 | + * otherwise re-generates it and saves it to the option |
|
259 | + * |
|
260 | + * @param string $version |
|
261 | + * @param boolean $hidden_endpoints |
|
262 | + * @return array |
|
263 | + */ |
|
264 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
265 | + { |
|
266 | + $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
267 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
268 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
269 | + } |
|
270 | + return $ee_routes; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Saves the EE REST API route data to a wp option and returns it |
|
277 | + * |
|
278 | + * @param string $version |
|
279 | + * @param boolean $hidden_endpoints |
|
280 | + * @return mixed|null|void |
|
281 | + */ |
|
282 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
283 | + { |
|
284 | + $instance = self::instance(); |
|
285 | + $routes = apply_filters( |
|
286 | + 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
|
287 | + array_replace_recursive( |
|
288 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
289 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
290 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
291 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
292 | + ) |
|
293 | + ); |
|
294 | + $option_name = self::saved_routes_option_names . $version; |
|
295 | + if (get_option($option_name)) { |
|
296 | + update_option($option_name, $routes, true); |
|
297 | + } else { |
|
298 | + add_option($option_name, $routes, null, 'no'); |
|
299 | + } |
|
300 | + return $routes; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * Calculates all the EE routes and saves it to a wordpress option so we don't |
|
307 | + * need to calculate it on every request |
|
308 | + * |
|
309 | + * @deprecated since version 4.9.1 |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + public static function save_ee_routes() |
|
313 | + { |
|
314 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
315 | + $instance = self::instance(); |
|
316 | + $routes = apply_filters( |
|
317 | + 'EED_Core_Rest_Api__save_ee_routes__routes', |
|
318 | + array_replace_recursive( |
|
319 | + $instance->_register_config_routes(), |
|
320 | + $instance->_register_meta_routes(), |
|
321 | + $instance->_register_model_routes(), |
|
322 | + $instance->_register_rpc_routes() |
|
323 | + ) |
|
324 | + ); |
|
325 | + update_option(self::saved_routes_option_names, $routes, true); |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * Gets all the route information relating to EE models |
|
333 | + * |
|
334 | + * @return array @see get_ee_route_data |
|
335 | + * @deprecated since version 4.9.1 |
|
336 | + */ |
|
337 | + protected function _register_model_routes() |
|
338 | + { |
|
339 | + $model_routes = array(); |
|
340 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
341 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace |
|
342 | + . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
343 | + } |
|
344 | + return $model_routes; |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * Gets the route data for EE models in the specified version |
|
351 | + * |
|
352 | + * @param string $version |
|
353 | + * @param boolean $hidden_endpoint |
|
354 | + * @return array |
|
355 | + */ |
|
356 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) |
|
357 | + { |
|
358 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
359 | + $models_to_register = apply_filters( |
|
360 | + 'FHEE__EED_Core_REST_API___register_model_routes', |
|
361 | + $model_version_info->models_for_requested_version() |
|
362 | + ); |
|
363 | + //let's not bother having endpoints for extra metas |
|
364 | + unset($models_to_register['Extra_Meta']); |
|
365 | + unset($models_to_register['Extra_Join']); |
|
366 | + $model_routes = array(); |
|
367 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
368 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
369 | + //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
|
370 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
371 | + $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
372 | + $model_routes[$plural_model_route] = array( |
|
373 | + array( |
|
374 | + 'callback' => array( |
|
375 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
376 | + 'handle_request_get_all', |
|
377 | + ), |
|
378 | + 'methods' => WP_REST_Server::READABLE, |
|
379 | + 'hidden_endpoint' => $hidden_endpoint, |
|
380 | + 'args' => $this->_get_read_query_params($model, $version), |
|
381 | + '_links' => array( |
|
382 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
383 | + ), |
|
384 | + ), |
|
385 | + // array( |
|
386 | + // 'callback' => array( |
|
387 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
388 | + // 'handle_request_create_one' ), |
|
389 | + // 'methods' => WP_REST_Server::CREATABLE, |
|
390 | + // 'hidden_endpoint' => $hidden_endpoint |
|
391 | + // ) |
|
392 | + ); |
|
393 | + $model_routes[$singular_model_route] = array( |
|
394 | + array( |
|
395 | + 'callback' => array( |
|
396 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
397 | + 'handle_request_get_one', |
|
398 | + ), |
|
399 | + 'methods' => WP_REST_Server::READABLE, |
|
400 | + 'hidden_endpoint' => $hidden_endpoint, |
|
401 | + 'args' => $this->_get_response_selection_query_params($model, $version), |
|
402 | + ), |
|
403 | + // array( |
|
404 | + // 'callback' => array( |
|
405 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
406 | + // 'handle_request_edit_one' ), |
|
407 | + // 'methods' => WP_REST_Server::EDITABLE, |
|
408 | + // 'hidden_endpoint' => $hidden_endpoint |
|
409 | + // ), |
|
410 | + ); |
|
411 | + //@todo: also handle DELETE for a single item |
|
412 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
413 | + $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
|
414 | + $relation_name, |
|
415 | + $relation_obj |
|
416 | + ); |
|
417 | + $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
418 | + array( |
|
419 | + 'callback' => array( |
|
420 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
421 | + 'handle_request_get_related', |
|
422 | + ), |
|
423 | + 'methods' => WP_REST_Server::READABLE, |
|
424 | + 'hidden_endpoint' => $hidden_endpoint, |
|
425 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
426 | + ), |
|
427 | + // array( |
|
428 | + // 'callback' => array( |
|
429 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
430 | + // 'handle_request_create_or_update_related' ), |
|
431 | + // 'methods' => WP_REST_Server::EDITABLE, |
|
432 | + // 'hidden_endpoint' => $hidden_endpoint |
|
433 | + // ) |
|
434 | + ); |
|
435 | + //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish) |
|
436 | + } |
|
437 | + } |
|
438 | + return $model_routes; |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * Adds all the RPC-style routes (remote procedure call-like routes, ie |
|
445 | + * routes that don't conform to the traditional REST CRUD-style). |
|
446 | + * |
|
447 | + * @deprecated since 4.9.1 |
|
448 | + */ |
|
449 | + protected function _register_rpc_routes() |
|
450 | + { |
|
451 | + $routes = array(); |
|
452 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
453 | + $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | + $hidden_endpoint); |
|
455 | + } |
|
456 | + return $routes; |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * @param string $version |
|
463 | + * @param boolean $hidden_endpoint |
|
464 | + * @return array |
|
465 | + */ |
|
466 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) |
|
467 | + { |
|
468 | + $this_versions_routes = array(); |
|
469 | + //checkin endpoint |
|
470 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
471 | + array( |
|
472 | + 'callback' => array( |
|
473 | + 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
|
474 | + 'handle_request_toggle_checkin', |
|
475 | + ), |
|
476 | + 'methods' => WP_REST_Server::CREATABLE, |
|
477 | + 'hidden_endpoint' => $hidden_endpoint, |
|
478 | + 'args' => array( |
|
479 | + 'force' => array( |
|
480 | + 'required' => false, |
|
481 | + 'default' => false, |
|
482 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', |
|
483 | + 'event_espresso'), |
|
484 | + ), |
|
485 | + ), |
|
486 | + ), |
|
487 | + ); |
|
488 | + return apply_filters( |
|
489 | + 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
490 | + $this_versions_routes, |
|
491 | + $version, |
|
492 | + $hidden_endpoint |
|
493 | + ); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * Gets the query params that can be used when request one or many |
|
500 | + * |
|
501 | + * @param EEM_Base $model |
|
502 | + * @param string $version |
|
503 | + * @return array |
|
504 | + */ |
|
505 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) |
|
506 | + { |
|
507 | + return apply_filters( |
|
508 | + 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
|
509 | + array( |
|
510 | + 'include' => array( |
|
511 | + 'required' => false, |
|
512 | + 'default' => '*', |
|
513 | + ), |
|
514 | + 'calculate' => array( |
|
515 | + 'required' => false, |
|
516 | + 'default' => '', |
|
517 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model), |
|
518 | + ), |
|
519 | + ), |
|
520 | + $model, |
|
521 | + $version |
|
522 | + ); |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + |
|
527 | + /** |
|
528 | + * Gets info about reading query params that are acceptable |
|
529 | + * |
|
530 | + * @param \EEM_Base $model eg 'Event' or 'Venue' |
|
531 | + * @param string $version |
|
532 | + * @return array describing the args acceptable when querying this model |
|
533 | + * @throws \EE_Error |
|
534 | + */ |
|
535 | + protected function _get_read_query_params(\EEM_Base $model, $version) |
|
536 | + { |
|
537 | + $default_orderby = array(); |
|
538 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
539 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
540 | + } |
|
541 | + return array_merge( |
|
542 | + $this->_get_response_selection_query_params($model, $version), |
|
543 | + array( |
|
544 | + 'where' => array( |
|
545 | + 'required' => false, |
|
546 | + 'default' => array(), |
|
547 | + ), |
|
548 | + 'limit' => array( |
|
549 | + 'required' => false, |
|
550 | + 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
|
551 | + ), |
|
552 | + 'order_by' => array( |
|
553 | + 'required' => false, |
|
554 | + 'default' => $default_orderby, |
|
555 | + ), |
|
556 | + 'group_by' => array( |
|
557 | + 'required' => false, |
|
558 | + 'default' => null, |
|
559 | + ), |
|
560 | + 'having' => array( |
|
561 | + 'required' => false, |
|
562 | + 'default' => null, |
|
563 | + ), |
|
564 | + 'caps' => array( |
|
565 | + 'required' => false, |
|
566 | + 'default' => EEM_Base::caps_read, |
|
567 | + ), |
|
568 | + ) |
|
569 | + ); |
|
570 | + } |
|
571 | + |
|
572 | + |
|
573 | + |
|
574 | + /** |
|
575 | + * Gets routes for the config |
|
576 | + * |
|
577 | + * @return array @see _register_model_routes |
|
578 | + * @deprecated since version 4.9.1 |
|
579 | + */ |
|
580 | + protected function _register_config_routes() |
|
581 | + { |
|
582 | + $config_routes = array(); |
|
583 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
584 | + $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
585 | + $hidden_endpoint); |
|
586 | + } |
|
587 | + return $config_routes; |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * Gets routes for the config for the specified version |
|
594 | + * |
|
595 | + * @param string $version |
|
596 | + * @param boolean $hidden_endpoint |
|
597 | + * @return array |
|
598 | + */ |
|
599 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) |
|
600 | + { |
|
601 | + return array( |
|
602 | + 'config' => array( |
|
603 | + array( |
|
604 | + 'callback' => array( |
|
605 | + 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
606 | + 'handle_request', |
|
607 | + ), |
|
608 | + 'methods' => WP_REST_Server::READABLE, |
|
609 | + 'hidden_endpoint' => $hidden_endpoint, |
|
610 | + ), |
|
611 | + ), |
|
612 | + 'site_info' => array( |
|
613 | + array( |
|
614 | + 'callback' => array( |
|
615 | + 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
616 | + 'handle_request_site_info', |
|
617 | + ), |
|
618 | + 'methods' => WP_REST_Server::READABLE, |
|
619 | + 'hidden_endpoint' => $hidden_endpoint, |
|
620 | + ), |
|
621 | + ), |
|
622 | + ); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * Gets the meta info routes |
|
629 | + * |
|
630 | + * @return array @see _register_model_routes |
|
631 | + * @deprecated since version 4.9.1 |
|
632 | + */ |
|
633 | + protected function _register_meta_routes() |
|
634 | + { |
|
635 | + $meta_routes = array(); |
|
636 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
637 | + $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
638 | + $hidden_endpoint); |
|
639 | + } |
|
640 | + return $meta_routes; |
|
641 | + } |
|
642 | + |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * @param string $version |
|
647 | + * @param boolean $hidden_endpoint |
|
648 | + * @return array |
|
649 | + */ |
|
650 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) |
|
651 | + { |
|
652 | + return array( |
|
653 | + 'resources' => array( |
|
654 | + array( |
|
655 | + 'callback' => array( |
|
656 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
|
657 | + 'handle_request_models_meta', |
|
658 | + ), |
|
659 | + 'methods' => WP_REST_Server::READABLE, |
|
660 | + 'hidden_endpoint' => $hidden_endpoint, |
|
661 | + ), |
|
662 | + ), |
|
663 | + ); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * Tries to hide old 4.6 endpoints from the |
|
670 | + * |
|
671 | + * @param array $route_data |
|
672 | + * @return array |
|
673 | + */ |
|
674 | + public static function hide_old_endpoints($route_data) |
|
675 | + { |
|
676 | + //allow API clients to override which endpoints get hidden, in case |
|
677 | + //they want to discover particular endpoints |
|
678 | + //also, we don't have access to the request so we have to just grab it from the superglobal |
|
679 | + $force_show_ee_namespace = ltrim( |
|
680 | + EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
681 | + '/' |
|
682 | + ); |
|
683 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
684 | + foreach ($relative_urls as $endpoint => $routes) { |
|
685 | + foreach ($routes as $route) { |
|
686 | + //by default, hide "hidden_endpoint"s, unless the request indicates |
|
687 | + //to $force_show_ee_namespace, in which case only show that one |
|
688 | + //namespace's endpoints (and hide all others) |
|
689 | + if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
690 | + || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
|
691 | + ) { |
|
692 | + $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
693 | + unset($route_data[$full_route]); |
|
694 | + } |
|
695 | + } |
|
696 | + } |
|
697 | + } |
|
698 | + return $route_data; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * Returns an array describing which versions of core support serving requests for. |
|
705 | + * Keys are core versions' major and minor version, and values are the |
|
706 | + * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like |
|
707 | + * data by just removing a few models and fields from the responses. However, 4.15 might remove |
|
708 | + * the answers table entirely, in which case it would be very difficult for |
|
709 | + * it to serve 4.6-style responses. |
|
710 | + * Versions of core that are missing from this array are unknowns. |
|
711 | + * previous ver |
|
712 | + * |
|
713 | + * @return array |
|
714 | + */ |
|
715 | + public static function version_compatibilities() |
|
716 | + { |
|
717 | + return apply_filters( |
|
718 | + 'FHEE__EED_Core_REST_API__version_compatibilities', |
|
719 | + array( |
|
720 | + '4.8.29' => '4.8.29', |
|
721 | + '4.8.33' => '4.8.29', |
|
722 | + '4.8.34' => '4.8.29', |
|
723 | + '4.8.36' => '4.8.29', |
|
724 | + ) |
|
725 | + ); |
|
726 | + } |
|
727 | + |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * Gets the latest API version served. Eg if there |
|
732 | + * are two versions served of the API, 4.8.29 and 4.8.32, and |
|
733 | + * we are on core version 4.8.34, it will return the string "4.8.32" |
|
734 | + * |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public static function latest_rest_api_version() |
|
738 | + { |
|
739 | + $versions_served = \EED_Core_Rest_Api::versions_served(); |
|
740 | + $versions_served_keys = array_keys($versions_served); |
|
741 | + return end($versions_served_keys); |
|
742 | + } |
|
743 | + |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of |
|
748 | + * EE the API can serve requests for. Eg, if we are on 4.15 of core, and |
|
749 | + * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ). |
|
750 | + * We also indicate whether or not this version should be put in the index or not |
|
751 | + * |
|
752 | + * @return array keys are API version numbers (just major and minor numbers), and values |
|
753 | + * are whether or not they should be hidden |
|
754 | + */ |
|
755 | + public static function versions_served() |
|
756 | + { |
|
757 | + $versions_served = array(); |
|
758 | + $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
|
759 | + $lowest_compatible_version = end($possibly_served_versions); |
|
760 | + reset($possibly_served_versions); |
|
761 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
762 | + $latest_version = end($versions_served_historically); |
|
763 | + reset($versions_served_historically); |
|
764 | + //for each version of core we have ever served: |
|
765 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
766 | + //if it's not above the current core version, and it's compatible with the current version of core |
|
767 | + if ($key_versioned_endpoint == $latest_version) { |
|
768 | + //don't hide the latest version in the index |
|
769 | + $versions_served[$key_versioned_endpoint] = false; |
|
770 | + } else if ( |
|
771 | + $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
|
772 | + && $key_versioned_endpoint >= $lowest_compatible_version |
|
773 | + ) { |
|
774 | + //include, but hide, previous versions which are still supported |
|
775 | + $versions_served[$key_versioned_endpoint] = true; |
|
776 | + } elseif ( |
|
777 | + apply_filters( |
|
778 | + 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
|
779 | + false, |
|
780 | + $possibly_served_versions |
|
781 | + ) |
|
782 | + ) { |
|
783 | + //if a version is no longer supported, don't include it in index or list of versions served |
|
784 | + $versions_served[$key_versioned_endpoint] = true; |
|
785 | + } |
|
786 | + } |
|
787 | + return $versions_served; |
|
788 | + } |
|
789 | + |
|
790 | + |
|
791 | + |
|
792 | + /** |
|
793 | + * Gets the major and minor version of EE core's version string |
|
794 | + * |
|
795 | + * @return string |
|
796 | + */ |
|
797 | + public static function core_version() |
|
798 | + { |
|
799 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', |
|
800 | + implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
801 | + } |
|
802 | + |
|
803 | + |
|
804 | + |
|
805 | + /** |
|
806 | + * Gets the default limit that should be used when querying for resources |
|
807 | + * |
|
808 | + * @return int |
|
809 | + */ |
|
810 | + public static function get_default_query_limit() |
|
811 | + { |
|
812 | + //we actually don't use a const because we want folks to always use |
|
813 | + //this method, not the const directly |
|
814 | + return apply_filters( |
|
815 | + 'FHEE__EED_Core_Rest_Api__get_default_query_limit', |
|
816 | + 50 |
|
817 | + ); |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + |
|
822 | + /** |
|
823 | + * run - initial module setup |
|
824 | + * |
|
825 | + * @access public |
|
826 | + * @param WP $WP |
|
827 | + * @return void |
|
828 | + */ |
|
829 | + public function run($WP) |
|
830 | + { |
|
831 | + } |
|
832 | 832 | |
833 | 833 | |
834 | 834 |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected static function _set_hooks_for_changes() |
159 | 159 | { |
160 | - $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
160 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
161 | 161 | foreach ($folder_contents as $classname_in_namespace => $filepath) { |
162 | 162 | //ignore the base parent class |
163 | 163 | if ($classname_in_namespace === 'Changes_In_Base') { |
164 | 164 | continue; |
165 | 165 | } |
166 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
166 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
167 | 167 | if (class_exists($full_classname)) { |
168 | 168 | $instance_of_class = new $full_classname; |
169 | 169 | if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | //delete the saved EE REST API routes |
228 | 228 | foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
229 | - delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
229 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | $ee_routes = array(); |
247 | 247 | foreach (self::versions_served() as $version => $hidden_endpoints) { |
248 | - $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
248 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, |
|
249 | 249 | $hidden_endpoints); |
250 | 250 | } |
251 | 251 | return $ee_routes; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
265 | 265 | { |
266 | - $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
266 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
267 | 267 | if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
268 | 268 | $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
269 | 269 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
292 | 292 | ) |
293 | 293 | ); |
294 | - $option_name = self::saved_routes_option_names . $version; |
|
294 | + $option_name = self::saved_routes_option_names.$version; |
|
295 | 295 | if (get_option($option_name)) { |
296 | 296 | update_option($option_name, $routes, true); |
297 | 297 | } else { |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $model = \EE_Registry::instance()->load_model($model_name); |
369 | 369 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
370 | 370 | $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
371 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
371 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
372 | 372 | $model_routes[$plural_model_route] = array( |
373 | 373 | array( |
374 | 374 | 'callback' => array( |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | 'hidden_endpoint' => $hidden_endpoint, |
380 | 380 | 'args' => $this->_get_read_query_params($model, $version), |
381 | 381 | '_links' => array( |
382 | - 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
382 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
383 | 383 | ), |
384 | 384 | ), |
385 | 385 | // array( |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $relation_name, |
415 | 415 | $relation_obj |
416 | 416 | ); |
417 | - $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
417 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
418 | 418 | array( |
419 | 419 | 'callback' => array( |
420 | 420 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | { |
451 | 451 | $routes = array(); |
452 | 452 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
453 | - $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
453 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | 454 | $hidden_endpoint); |
455 | 455 | } |
456 | 456 | return $routes; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | { |
582 | 582 | $config_routes = array(); |
583 | 583 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
584 | - $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
584 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, |
|
585 | 585 | $hidden_endpoint); |
586 | 586 | } |
587 | 587 | return $config_routes; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | { |
635 | 635 | $meta_routes = array(); |
636 | 636 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
637 | - $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
637 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, |
|
638 | 638 | $hidden_endpoint); |
639 | 639 | } |
640 | 640 | return $meta_routes; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
690 | 690 | || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
691 | 691 | ) { |
692 | - $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
692 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
693 | 693 | unset($route_data[$full_route]); |
694 | 694 | } |
695 | 695 | } |