@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * @package Event Espresso |
8 | 8 | * @subpackage core, capabilities |
9 | 9 | */ |
10 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
11 | - exit( 'No direct script access allowed' ); |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function instance() { |
71 | 71 | //check if instantiated, and if not do so. |
72 | - if ( ! self::$_instance instanceof EE_Capabilities ) { |
|
72 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | } |
75 | 75 | return self::$_instance; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @since 4.5.0 |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function init_caps( $reset = false ) { |
|
102 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
101 | + public function init_caps($reset = false) { |
|
102 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
103 | 103 | $this->_caps_map = $this->_init_caps_map(); |
104 | - $this->init_role_caps( $reset ); |
|
104 | + $this->init_role_caps($reset); |
|
105 | 105 | $this->_set_meta_caps(); |
106 | 106 | } |
107 | 107 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
121 | 121 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
122 | 122 | |
123 | - $this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps ); |
|
123 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
124 | 124 | |
125 | 125 | //add filter for map_meta_caps but only if models can query. |
126 | - if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) { |
|
127 | - add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 ); |
|
126 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
127 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function _get_default_meta_caps_array() { |
139 | 139 | static $default_meta_caps = array(); |
140 | - if ( empty( $default_meta_caps ) ) { |
|
140 | + if (empty($default_meta_caps)) { |
|
141 | 141 | $default_meta_caps = array( |
142 | 142 | //edits |
143 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ), |
|
144 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ), |
|
145 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ), |
|
146 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ), |
|
147 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ), |
|
148 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ), |
|
149 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ), |
|
150 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ), |
|
151 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ), |
|
143 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
144 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
145 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')), |
|
146 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')), |
|
147 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
148 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
149 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')), |
|
150 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
151 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
152 | 152 | //reads |
153 | - new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ), |
|
154 | - new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ), |
|
155 | - new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ), |
|
156 | - new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ), |
|
157 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ), |
|
158 | - new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ), |
|
159 | - new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ), |
|
153 | + new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
154 | + new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
155 | + new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')), |
|
156 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')), |
|
157 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
158 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
159 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
160 | 160 | |
161 | 161 | //deletes |
162 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ), |
|
163 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ), |
|
164 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ), |
|
165 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ), |
|
166 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ), |
|
167 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ), |
|
168 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ), |
|
169 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ), |
|
170 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ), |
|
162 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')), |
|
163 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')), |
|
164 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')), |
|
165 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')), |
|
166 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
167 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
168 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')), |
|
169 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')), |
|
170 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | return $default_meta_caps; |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array actual users capabilities |
193 | 193 | */ |
194 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
194 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
195 | 195 | //loop through our _meta_caps array |
196 | - foreach ( $this->_meta_caps as $meta_map ) { |
|
197 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map ) { |
|
196 | + foreach ($this->_meta_caps as $meta_map) { |
|
197 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | $meta_map->ensure_is_model(); |
201 | 201 | |
202 | - $caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args ); |
|
202 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
203 | 203 | } |
204 | 204 | return $caps; |
205 | 205 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - $caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps ); |
|
367 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
368 | 368 | return $caps; |
369 | 369 | } |
370 | 370 | |
@@ -381,26 +381,26 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public function init_role_caps( $reset = false, $custom_map = array() ) { |
|
384 | + public function init_role_caps($reset = false, $custom_map = array()) { |
|
385 | 385 | |
386 | - $caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map; |
|
386 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
387 | 387 | |
388 | 388 | //first let's determine if these caps have already been set. |
389 | - $caps_set_before = get_option( self::option_name, array() ); |
|
389 | + $caps_set_before = get_option(self::option_name, array()); |
|
390 | 390 | //if not reset, see what caps are new for each role. if they're new, add them. |
391 | - foreach ( $caps_map as $role => $caps_for_role ) { |
|
392 | - foreach ( $caps_for_role as $cap ) { |
|
391 | + foreach ($caps_map as $role => $caps_for_role) { |
|
392 | + foreach ($caps_for_role as $cap) { |
|
393 | 393 | //first check we haven't already added this cap before, or it's a reset |
394 | - if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) { |
|
395 | - $this->add_cap_to_role( $role, $cap ); |
|
396 | - $caps_set_before[ $role ][] = $cap; |
|
394 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
395 | + $this->add_cap_to_role($role, $cap); |
|
396 | + $caps_set_before[$role][] = $cap; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | 401 | //now let's just save the cap that has been set. |
402 | - update_option( self::option_name, $caps_set_before ); |
|
403 | - do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before ); |
|
402 | + update_option(self::option_name, $caps_set_before); |
|
403 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | * @param bool $grant Whether to grant access to this cap on this role. |
420 | 420 | * @return void |
421 | 421 | */ |
422 | - public function add_cap_to_role( $role, $cap, $grant = true ) { |
|
423 | - $role = get_role( $role ); |
|
424 | - if ( $role instanceof WP_Role ) { |
|
425 | - $role->add_cap( $cap, $grant ); |
|
422 | + public function add_cap_to_role($role, $cap, $grant = true) { |
|
423 | + $role = get_role($role); |
|
424 | + if ($role instanceof WP_Role) { |
|
425 | + $role->add_cap($cap, $grant); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return void |
444 | 444 | */ |
445 | - public function remove_cap_from_role( $role, $cap ) { |
|
446 | - $role = get_role( $role ); |
|
447 | - if ( $role instanceof WP_Role ) { |
|
448 | - $role->remove_cap( $cap ); |
|
445 | + public function remove_cap_from_role($role, $cap) { |
|
446 | + $role = get_role($role); |
|
447 | + if ($role instanceof WP_Role) { |
|
448 | + $role->remove_cap($cap); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return bool Whether user can or not. |
468 | 468 | */ |
469 | - public function current_user_can( $cap, $context, $id = 0 ) { |
|
469 | + public function current_user_can($cap, $context, $id = 0) { |
|
470 | 470 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
471 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id ); |
|
472 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id ); |
|
473 | - return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap ); |
|
471 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
472 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id); |
|
473 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @return bool Whether user can or not. |
489 | 489 | */ |
490 | - public function user_can( $user, $cap, $context, $id = 0 ) { |
|
490 | + public function user_can($user, $cap, $context, $id = 0) { |
|
491 | 491 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
492 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id ); |
|
493 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id ); |
|
494 | - return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap ); |
|
492 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
493 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id); |
|
494 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @return bool Whether user can or not. |
513 | 513 | */ |
514 | - public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) { |
|
515 | - $user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap ); |
|
514 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) { |
|
515 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
516 | 516 | |
517 | 517 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
518 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id ); |
|
519 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id ); |
|
518 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id); |
|
519 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id); |
|
520 | 520 | return $user_can; |
521 | 521 | } |
522 | 522 | |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return array |
534 | 534 | */ |
535 | - public function get_ee_capabilities( $role = 'administrator' ) { |
|
535 | + public function get_ee_capabilities($role = 'administrator') { |
|
536 | 536 | $capabilities = $this->_init_caps_map(); |
537 | - if ( empty( $role ) ) { |
|
537 | + if (empty($role)) { |
|
538 | 538 | return $capabilities; |
539 | 539 | } |
540 | - return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array(); |
|
540 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | * } |
586 | 586 | * @throws EE_Error |
587 | 587 | */ |
588 | - public function __construct( $meta_cap, $map_values ) { |
|
588 | + public function __construct($meta_cap, $map_values) { |
|
589 | 589 | $this->meta_cap = $meta_cap; |
590 | 590 | //verify there are four args in the $map_values array; |
591 | - if ( count( $map_values ) !== 4 ) { |
|
592 | - throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) ); |
|
591 | + if (count($map_values) !== 4) { |
|
592 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | //set properties |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * Makes it so this object stops filtering caps |
605 | 605 | */ |
606 | - public function remove_filters(){ |
|
607 | - remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 ); |
|
606 | + public function remove_filters() { |
|
607 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | */ |
620 | 620 | public function ensure_is_model() { |
621 | 621 | //is it already instantiated? |
622 | - if ( $this->_model instanceof EEM_Base ) { |
|
622 | + if ($this->_model instanceof EEM_Base) { |
|
623 | 623 | return; |
624 | 624 | } |
625 | 625 | |
626 | 626 | //ensure model name is string |
627 | 627 | $this->_model_name = (string) $this->_model_name; |
628 | 628 | //error proof if the name has EEM in it |
629 | - $this->_model_name = str_replace( 'EEM', '', $this->_model_name ); |
|
629 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
630 | 630 | |
631 | - $this->_model = EE_Registry::instance()->load_model( $this->_model_name ); |
|
631 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
632 | 632 | |
633 | - if ( ! $this->_model instanceof EEM_Base ) { |
|
634 | - throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) ); |
|
633 | + if ( ! $this->_model instanceof EEM_Base) { |
|
634 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model)); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * |
648 | 648 | * @return array |
649 | 649 | */ |
650 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
651 | - return $this->_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
650 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
651 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return array actual users capabilities |
668 | 668 | */ |
669 | - abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args ); |
|
669 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -698,28 +698,28 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return array actual users capabilities |
700 | 700 | */ |
701 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
701 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
702 | 702 | //only process if we're checking our mapped_cap |
703 | - if ( $cap !== $this->meta_cap ) { |
|
703 | + if ($cap !== $this->meta_cap) { |
|
704 | 704 | return $caps; |
705 | 705 | } |
706 | 706 | |
707 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
707 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
708 | 708 | |
709 | 709 | //if no obj then let's just do cap |
710 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
710 | + if ( ! $obj instanceof EE_Base_Class) { |
|
711 | 711 | $caps[] = $cap; |
712 | 712 | return $caps; |
713 | 713 | } |
714 | 714 | |
715 | - if ( $obj instanceof EE_CPT_Base ) { |
|
715 | + if ($obj instanceof EE_CPT_Base) { |
|
716 | 716 | //if the item author is set and the user is the author... |
717 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
718 | - if ( empty( $this->published_cap ) ) { |
|
717 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
718 | + if (empty($this->published_cap)) { |
|
719 | 719 | $caps[] = $cap; |
720 | 720 | } else { |
721 | 721 | //if obj is published... |
722 | - if ( $obj->status() == 'publish' ) { |
|
722 | + if ($obj->status() == 'publish') { |
|
723 | 723 | $caps[] = $this->published_cap; |
724 | 724 | } else { |
725 | 725 | $caps[] = $cap; |
@@ -727,21 +727,21 @@ discard block |
||
727 | 727 | } |
728 | 728 | } else { |
729 | 729 | //the user is trying to edit someone else's obj |
730 | - if ( ! empty( $this->others_cap ) ) { |
|
730 | + if ( ! empty($this->others_cap)) { |
|
731 | 731 | $caps[] = $this->others_cap; |
732 | 732 | } |
733 | - if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) { |
|
733 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
734 | 734 | $caps[] = $this->published_cap; |
735 | - } elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) { |
|
735 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
736 | 736 | $caps[] = $this->private_cap; |
737 | 737 | } |
738 | 738 | } |
739 | 739 | } else { |
740 | 740 | //not a cpt object so handled differently |
741 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
741 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
742 | 742 | $caps[] = $cap; |
743 | 743 | } else { |
744 | - if ( ! empty( $this->others_cap ) ) { |
|
744 | + if ( ! empty($this->others_cap)) { |
|
745 | 745 | $caps[] = $this->others_cap; |
746 | 746 | } |
747 | 747 | } |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | * |
779 | 779 | * @return array actual users capabilities |
780 | 780 | */ |
781 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
782 | - return parent::_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
781 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
782 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
@@ -811,45 +811,45 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @return array actual users capabilities |
813 | 813 | */ |
814 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
814 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
815 | 815 | //only process if we're checking our mapped cap; |
816 | - if ( $cap !== $this->meta_cap ) { |
|
816 | + if ($cap !== $this->meta_cap) { |
|
817 | 817 | return $caps; |
818 | 818 | } |
819 | 819 | |
820 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
820 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
821 | 821 | |
822 | 822 | //if no obj then let's just do cap |
823 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
823 | + if ( ! $obj instanceof EE_Base_Class) { |
|
824 | 824 | $caps[] = $cap; |
825 | 825 | return $caps; |
826 | 826 | } |
827 | 827 | |
828 | - if ( $obj instanceof EE_CPT_Base ) { |
|
829 | - $status_obj = get_post_status_object( $obj->status() ); |
|
830 | - if ( $status_obj->public ) { |
|
828 | + if ($obj instanceof EE_CPT_Base) { |
|
829 | + $status_obj = get_post_status_object($obj->status()); |
|
830 | + if ($status_obj->public) { |
|
831 | 831 | $caps[] = $cap; |
832 | 832 | return $caps; |
833 | 833 | } |
834 | 834 | |
835 | 835 | //if the item author is set and the user is the author... |
836 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
836 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
837 | 837 | $caps[] = $cap; |
838 | - } elseif ( $status_obj->private && ! empty( $this->private_cap ) ) { |
|
838 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
839 | 839 | //the user is trying to view someone else's obj |
840 | 840 | $caps[] = $this->private_cap; |
841 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
841 | + } elseif ( ! empty($this->others_cap)) { |
|
842 | 842 | $caps[] = $this->others_cap; |
843 | 843 | } else { |
844 | 844 | $caps[] = $cap; |
845 | 845 | } |
846 | 846 | } else { |
847 | 847 | //not a cpt object so handled differently |
848 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
848 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
849 | 849 | $caps[] = $cap; |
850 | - } elseif ( ! empty( $this->private_cap ) ) { |
|
850 | + } elseif ( ! empty($this->private_cap)) { |
|
851 | 851 | $caps[] = $this->private_cap; |
852 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
852 | + } elseif ( ! empty($this->others_cap)) { |
|
853 | 853 | $caps[] = $this->others_cap; |
854 | 854 | } else { |
855 | 855 | $caps[] = $cap; |
@@ -886,30 +886,30 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return array actual users capabilities |
888 | 888 | */ |
889 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
889 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
890 | 890 | //only process if we're checking our mapped_cap |
891 | - if ( $cap !== $this->meta_cap ) { |
|
891 | + if ($cap !== $this->meta_cap) { |
|
892 | 892 | return $caps; |
893 | 893 | } |
894 | 894 | |
895 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
895 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
896 | 896 | |
897 | 897 | //if no obj then let's just do cap |
898 | - if ( ! $obj instanceof EE_Message_Template_Group ) { |
|
898 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
899 | 899 | $caps[] = $cap; |
900 | 900 | return $caps; |
901 | 901 | } |
902 | 902 | |
903 | 903 | $is_global = $obj->is_global(); |
904 | 904 | |
905 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
906 | - if ( $is_global ) { |
|
907 | - $caps[] = $this->private_cap; |
|
905 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
906 | + if ($is_global) { |
|
907 | + $caps[] = $this->private_cap; |
|
908 | 908 | } else { |
909 | 909 | $caps[] = $cap; |
910 | 910 | } |
911 | 911 | } else { |
912 | - if ( $is_global ) { |
|
912 | + if ($is_global) { |
|
913 | 913 | $caps[] = $this->private_cap; |
914 | 914 | } else { |
915 | 915 | $caps[] = $this->others_cap; |
@@ -947,16 +947,16 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return array actual users capabilities |
949 | 949 | */ |
950 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
950 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
951 | 951 | //only process if we're checking our mapped_cap |
952 | - if ( $cap !== $this->meta_cap ) { |
|
952 | + if ($cap !== $this->meta_cap) { |
|
953 | 953 | return $caps; |
954 | 954 | } |
955 | 955 | |
956 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
956 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
957 | 957 | |
958 | 958 | //if no obj then let's just do cap |
959 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
959 | + if ( ! $obj instanceof EE_Base_Class) { |
|
960 | 960 | $caps[] = $cap; |
961 | 961 | return $caps; |
962 | 962 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
965 | 965 | $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
966 | 966 | |
967 | - if ( $is_system ) { |
|
967 | + if ($is_system) { |
|
968 | 968 | $caps[] = $this->private_cap; |
969 | 969 | } else { |
970 | 970 | $caps[] = $cap; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function instance() { |
104 | 104 | // check if class object is instantiated |
105 | - if ( ! self::$_instance instanceof EE_System ) { |
|
105 | + if ( ! self::$_instance instanceof EE_System) { |
|
106 | 106 | self::$_instance = new self(); |
107 | 107 | } |
108 | 108 | return self::$_instance; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * resets the instance and returns it |
114 | 114 | * @return EE_System |
115 | 115 | */ |
116 | - public static function reset(){ |
|
116 | + public static function reset() { |
|
117 | 117 | self::$_instance->_req_type = NULL; |
118 | 118 | //we need to reset the migration manager in order for it to detect DMSs properly |
119 | 119 | EE_Data_Migration_Manager::reset(); |
120 | 120 | //make sure none of the old hooks are left hanging around |
121 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
121 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
122 | 122 | self::instance()->detect_activations_or_upgrades(); |
123 | 123 | self::instance()->perform_activations_upgrades_and_migrations(); |
124 | 124 | return self::instance(); |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * @access private |
135 | 135 | */ |
136 | 136 | private function __construct() { |
137 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
137 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
138 | 138 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
140 | 140 | // when an ee addon is activated, we want to call the core hook(s) again |
141 | 141 | // because the newly-activated addon didn't get a chance to run at all |
142 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
142 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
143 | 143 | // detect whether install or upgrade |
144 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
144 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
145 | 145 | // load EE_Config, EE_Textdomain, etc |
146 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
146 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
147 | 147 | // load EE_Config, EE_Textdomain, etc |
148 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
148 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
149 | 149 | // you wanna get going? I wanna get going... let's get going! |
150 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
150 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
151 | 151 | //other housekeeping |
152 | 152 | //exclude EE critical pages from wp_list_pages |
153 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
153 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
154 | 154 | // ALL EE Addons should use the following hook point to attach their initial setup too |
155 | 155 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
156 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
156 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | public function load_espresso_addons() { |
174 | 174 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
175 | 175 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
176 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
176 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
177 | 177 | //load and setup EE_Capabilities |
178 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
178 | + EE_Registry::instance()->load_core('Capabilities'); |
|
179 | 179 | //caps need to be initialized on every request so that capability maps are set. |
180 | 180 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
181 | 181 | EE_Registry::instance()->CAP->init_caps(); |
182 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
182 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | * @access public |
195 | 195 | * @return void |
196 | 196 | */ |
197 | - public function detect_activations_or_upgrades(){ |
|
197 | + public function detect_activations_or_upgrades() { |
|
198 | 198 | //first off: let's make sure to handle core |
199 | 199 | $this->detect_if_activation_or_upgrade(); |
200 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
200 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
201 | 201 | //detect teh request type for that addon |
202 | 202 | $addon->detect_activation_or_upgrade(); |
203 | 203 | } |
@@ -218,44 +218,44 @@ discard block |
||
218 | 218 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
219 | 219 | |
220 | 220 | // load M-Mode class |
221 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
221 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
222 | 222 | // check if db has been updated, or if its a brand-new installation |
223 | 223 | |
224 | 224 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
225 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
225 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
226 | 226 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
227 | - if( $request_type != EE_System::req_type_normal){ |
|
227 | + if ($request_type != EE_System::req_type_normal) { |
|
228 | 228 | EE_Registry::instance()->load_helper('Activation'); |
229 | 229 | } |
230 | 230 | |
231 | - switch($request_type){ |
|
231 | + switch ($request_type) { |
|
232 | 232 | case EE_System::req_type_new_activation: |
233 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
234 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
233 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
234 | + $this->_handle_core_version_change($espresso_db_update); |
|
235 | 235 | break; |
236 | 236 | case EE_System::req_type_reactivation: |
237 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
238 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
237 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
238 | + $this->_handle_core_version_change($espresso_db_update); |
|
239 | 239 | break; |
240 | 240 | case EE_System::req_type_upgrade: |
241 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
241 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
242 | 242 | //migrations may be required now that we've upgraded |
243 | 243 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
244 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
244 | + $this->_handle_core_version_change($espresso_db_update); |
|
245 | 245 | // echo "done upgrade";die; |
246 | 246 | break; |
247 | 247 | case EE_System::req_type_downgrade: |
248 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
248 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
249 | 249 | //its possible migrations are no longer required |
250 | 250 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
251 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
251 | + $this->_handle_core_version_change($espresso_db_update); |
|
252 | 252 | break; |
253 | 253 | case EE_System::req_type_normal: |
254 | 254 | default: |
255 | 255 | // $this->_maybe_redirect_to_ee_about(); |
256 | 256 | break; |
257 | 257 | } |
258 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
258 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * initializing the database later during the request |
264 | 264 | * @param array $espresso_db_update |
265 | 265 | */ |
266 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
267 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
266 | + protected function _handle_core_version_change($espresso_db_update) { |
|
267 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
268 | 268 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
269 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
269 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -281,44 +281,44 @@ discard block |
||
281 | 281 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
282 | 282 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
283 | 283 | */ |
284 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
285 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
286 | - if( ! $espresso_db_update){ |
|
287 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
284 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
285 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
286 | + if ( ! $espresso_db_update) { |
|
287 | + $espresso_db_update = get_option('espresso_db_update'); |
|
288 | 288 | } |
289 | 289 | // check that option is an array |
290 | - if( ! is_array( $espresso_db_update )) { |
|
290 | + if ( ! is_array($espresso_db_update)) { |
|
291 | 291 | // if option is FALSE, then it never existed |
292 | - if ( $espresso_db_update === FALSE ) { |
|
292 | + if ($espresso_db_update === FALSE) { |
|
293 | 293 | // make $espresso_db_update an array and save option with autoload OFF |
294 | - $espresso_db_update = array(); |
|
295 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
294 | + $espresso_db_update = array(); |
|
295 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
296 | 296 | } else { |
297 | 297 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
298 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
299 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
298 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
299 | + update_option('espresso_db_update', $espresso_db_update); |
|
300 | 300 | } |
301 | - }else{ |
|
301 | + } else { |
|
302 | 302 | $corrected_db_update = array(); |
303 | 303 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
304 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
305 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
304 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
305 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
306 | 306 | //the key is an int, and the value IS NOT an array |
307 | 307 | //so it must be numerically-indexed, where values are versions installed... |
308 | 308 | //fix it! |
309 | 309 | $version_string = $should_be_array; |
310 | 310 | $corrected_db_update[$version_string] = array('unknown-date'); |
311 | - }else{ |
|
311 | + } else { |
|
312 | 312 | //ok it checks out |
313 | 313 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
314 | 314 | } |
315 | 315 | } |
316 | 316 | $espresso_db_update = $corrected_db_update; |
317 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
317 | + update_option('espresso_db_update', $espresso_db_update); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
321 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
321 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
322 | 322 | return $espresso_db_update; |
323 | 323 | } |
324 | 324 | |
@@ -337,33 +337,33 @@ discard block |
||
337 | 337 | * so we prefer to only do it when necessary |
338 | 338 | * @return void |
339 | 339 | */ |
340 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
340 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
341 | 341 | $request_type = $this->detect_req_type(); |
342 | 342 | //only initialize system if we're not in maintenance mode. |
343 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
344 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
343 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
344 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
345 | 345 | EEH_Activation::system_initialization(); |
346 | - if( $verify_schema ) { |
|
346 | + if ($verify_schema) { |
|
347 | 347 | EEH_Activation::initialize_db_and_folders(); |
348 | 348 | } |
349 | 349 | EEH_Activation::initialize_db_content(); |
350 | - if( $initialize_addons_too ) { |
|
350 | + if ($initialize_addons_too) { |
|
351 | 351 | $this->initialize_addons(); |
352 | 352 | } |
353 | - }else{ |
|
354 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
353 | + } else { |
|
354 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
355 | 355 | } |
356 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
357 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
356 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
357 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | 362 | * Initializes the db for all registered addons |
363 | 363 | */ |
364 | - public function initialize_addons(){ |
|
364 | + public function initialize_addons() { |
|
365 | 365 | //foreach registered addon, make sure its db is up-to-date too |
366 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
366 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
367 | 367 | $addon->initialize_db_if_no_migrations_required(); |
368 | 368 | } |
369 | 369 | } |
@@ -375,16 +375,16 @@ discard block |
||
375 | 375 | * @param string $current_version_to_add version to be added to the version history |
376 | 376 | * @return boolean success as to whether or not this option was changed |
377 | 377 | */ |
378 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
379 | - if( ! $version_history ) { |
|
378 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
379 | + if ( ! $version_history) { |
|
380 | 380 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
381 | 381 | } |
382 | - if( $current_version_to_add == NULL){ |
|
382 | + if ($current_version_to_add == NULL) { |
|
383 | 383 | $current_version_to_add = espresso_version(); |
384 | 384 | } |
385 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
385 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
386 | 386 | // re-save |
387 | - return update_option( 'espresso_db_update', $version_history ); |
|
387 | + return update_option('espresso_db_update', $version_history); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | * but still know if this is a new install or not |
402 | 402 | * @return int one of the constants on EE_System::req_type_ |
403 | 403 | */ |
404 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
405 | - if ( $this->_req_type === NULL ){ |
|
406 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
407 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
404 | + public function detect_req_type($espresso_db_update = NULL) { |
|
405 | + if ($this->_req_type === NULL) { |
|
406 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
407 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
408 | 408 | } |
409 | 409 | return $this->_req_type; |
410 | 410 | } |
@@ -420,39 +420,39 @@ discard block |
||
420 | 420 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
421 | 421 | * @return int one of the constants on EE_System::req_type_* |
422 | 422 | */ |
423 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
424 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
425 | - if( $activation_history_for_addon ){ |
|
423 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
424 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
425 | + if ($activation_history_for_addon) { |
|
426 | 426 | //it exists, so this isn't a completely new install |
427 | 427 | //check if this version already in that list of previously installed versions |
428 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
428 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
429 | 429 | //it a version we haven't seen before |
430 | - if( $version_is_higher === 1 ){ |
|
430 | + if ($version_is_higher === 1) { |
|
431 | 431 | $req_type = EE_System::req_type_upgrade; |
432 | - }else{ |
|
432 | + } else { |
|
433 | 433 | $req_type = EE_System::req_type_downgrade; |
434 | 434 | } |
435 | - delete_option( $activation_indicator_option_name ); |
|
435 | + delete_option($activation_indicator_option_name); |
|
436 | 436 | } else { |
437 | 437 | // its not an update. maybe a reactivation? |
438 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
439 | - if ( $version_is_higher === -1 ){ |
|
438 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
439 | + if ($version_is_higher === -1) { |
|
440 | 440 | $req_type = EE_System::req_type_downgrade; |
441 | - }elseif( $version_is_higher === 0 ){ |
|
441 | + }elseif ($version_is_higher === 0) { |
|
442 | 442 | //we've seen this version before, but it's an activation. must be a reactivation |
443 | 443 | $req_type = EE_System::req_type_reactivation; |
444 | - }else{//$version_is_higher === 1 |
|
444 | + } else {//$version_is_higher === 1 |
|
445 | 445 | $req_type = EE_System::req_type_upgrade; |
446 | 446 | } |
447 | - delete_option( $activation_indicator_option_name ); |
|
447 | + delete_option($activation_indicator_option_name); |
|
448 | 448 | } else { |
449 | 449 | //we've seen this version before and the activation indicate doesn't show it was just activated |
450 | - if ( $version_is_higher === -1 ){ |
|
450 | + if ($version_is_higher === -1) { |
|
451 | 451 | $req_type = EE_System::req_type_downgrade; |
452 | - }elseif( $version_is_higher === 0 ){ |
|
452 | + }elseif ($version_is_higher === 0) { |
|
453 | 453 | //we've seen this version before and it's not an activation. its normal request |
454 | 454 | $req_type = EE_System::req_type_normal; |
455 | - }else{//$version_is_higher === 1 |
|
455 | + } else {//$version_is_higher === 1 |
|
456 | 456 | $req_type = EE_System::req_type_upgrade; |
457 | 457 | } |
458 | 458 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | } else { |
461 | 461 | //brand new install |
462 | 462 | $req_type = EE_System::req_type_new_activation; |
463 | - delete_option( $activation_indicator_option_name ); |
|
463 | + delete_option($activation_indicator_option_name); |
|
464 | 464 | } |
465 | 465 | return $req_type; |
466 | 466 | } |
@@ -478,30 +478,30 @@ discard block |
||
478 | 478 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
479 | 479 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
480 | 480 | */ |
481 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
481 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
482 | 482 | //find the most recently-activated version |
483 | 483 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
484 | 484 | $most_recently_active_version = '0.0.0.dev.000'; |
485 | - if( is_array( $activation_history_for_addon ) ){ |
|
486 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
485 | + if (is_array($activation_history_for_addon)) { |
|
486 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
487 | 487 | //check there is a record of when this version was activated. Otherwise, |
488 | 488 | //mark it as unknown |
489 | - if( ! $times_activated ){ |
|
490 | - $times_activated = array( 'unknown-date'); |
|
489 | + if ( ! $times_activated) { |
|
490 | + $times_activated = array('unknown-date'); |
|
491 | 491 | } |
492 | - if( is_string( $times_activated ) ){ |
|
493 | - $times_activated = array( $times_activated ); |
|
492 | + if (is_string($times_activated)) { |
|
493 | + $times_activated = array($times_activated); |
|
494 | 494 | } |
495 | - foreach( $times_activated as $an_activation ){ |
|
496 | - if( $an_activation != 'unknown-date' && |
|
497 | - $an_activation > $most_recently_active_version_activation ){ |
|
495 | + foreach ($times_activated as $an_activation) { |
|
496 | + if ($an_activation != 'unknown-date' && |
|
497 | + $an_activation > $most_recently_active_version_activation) { |
|
498 | 498 | $most_recently_active_version = $version; |
499 | 499 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
500 | 500 | } |
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
504 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
504 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -511,20 +511,20 @@ discard block |
||
511 | 511 | * @return void |
512 | 512 | */ |
513 | 513 | public function redirect_to_about_ee() { |
514 | - $notices = EE_Error::get_notices( FALSE ); |
|
514 | + $notices = EE_Error::get_notices(FALSE); |
|
515 | 515 | //if current user is an admin and it's not an ajax request |
516 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
517 | - $query_params = array( 'page' => 'espresso_about' ); |
|
516 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
517 | + $query_params = array('page' => 'espresso_about'); |
|
518 | 518 | |
519 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
519 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
520 | 520 | $query_params['new_activation'] = TRUE; |
521 | 521 | } |
522 | 522 | |
523 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
523 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
524 | 524 | $query_params['reactivation'] = TRUE; |
525 | 525 | } |
526 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
527 | - wp_safe_redirect( $url ); |
|
526 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
527 | + wp_safe_redirect($url); |
|
528 | 528 | exit(); |
529 | 529 | } |
530 | 530 | } |
@@ -538,31 +538,31 @@ discard block |
||
538 | 538 | * |
539 | 539 | * @return void |
540 | 540 | */ |
541 | - public function load_core_configuration(){ |
|
542 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
543 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
541 | + public function load_core_configuration() { |
|
542 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
543 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
544 | 544 | //load textdomain |
545 | 545 | EE_Load_Textdomain::load_textdomain(); |
546 | 546 | // load and setup EE_Config and EE_Network_Config |
547 | - EE_Registry::instance()->load_core( 'Config' ); |
|
548 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
547 | + EE_Registry::instance()->load_core('Config'); |
|
548 | + EE_Registry::instance()->load_core('Network_Config'); |
|
549 | 549 | // setup autoloaders |
550 | 550 | // enable logging? |
551 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
552 | - EE_Registry::instance()->load_core( 'Log' ); |
|
551 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
552 | + EE_Registry::instance()->load_core('Log'); |
|
553 | 553 | } |
554 | 554 | // check for activation errors |
555 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
556 | - if ( $activation_errors ) { |
|
557 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
558 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
555 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
556 | + if ($activation_errors) { |
|
557 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
558 | + update_option('ee_plugin_activation_errors', FALSE); |
|
559 | 559 | } |
560 | 560 | // get model names |
561 | 561 | $this->_parse_model_names(); |
562 | 562 | |
563 | 563 | //load caf stuff a chance to play during the activation process too. |
564 | 564 | $this->_maybe_brew_regular(); |
565 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
565 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -571,23 +571,23 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @return void |
573 | 573 | */ |
574 | - private function _parse_model_names(){ |
|
574 | + private function _parse_model_names() { |
|
575 | 575 | //get all the files in the EE_MODELS folder that end in .model.php |
576 | - $models = glob( EE_MODELS.'*.model.php'); |
|
576 | + $models = glob(EE_MODELS.'*.model.php'); |
|
577 | 577 | $model_names = array(); |
578 | 578 | $non_abstract_db_models = array(); |
579 | - foreach( $models as $model ){ |
|
579 | + foreach ($models as $model) { |
|
580 | 580 | // get model classname |
581 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
582 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
581 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
582 | + $shortname = str_replace('EEM_', '', $classname); |
|
583 | 583 | $reflectionClass = new ReflectionClass($classname); |
584 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
584 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
585 | 585 | $non_abstract_db_models[$shortname] = $classname; |
586 | 586 | } |
587 | - $model_names[ $shortname ] = $classname; |
|
587 | + $model_names[$shortname] = $classname; |
|
588 | 588 | } |
589 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
590 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
589 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
590 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -597,8 +597,8 @@ discard block |
||
597 | 597 | * @return void |
598 | 598 | */ |
599 | 599 | private function _maybe_brew_regular() { |
600 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
601 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
600 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
601 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
@@ -615,9 +615,9 @@ discard block |
||
615 | 615 | * @return void |
616 | 616 | */ |
617 | 617 | public function register_shortcodes_modules_and_widgets() { |
618 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
618 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
619 | 619 | // check for addons using old hookpoint |
620 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
620 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
621 | 621 | $this->_incompatible_addon_error(); |
622 | 622 | } |
623 | 623 | } |
@@ -631,19 +631,19 @@ discard block |
||
631 | 631 | */ |
632 | 632 | private function _incompatible_addon_error() { |
633 | 633 | // get array of classes hooking into here |
634 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
635 | - if ( ! empty( $class_names )) { |
|
636 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
634 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
635 | + if ( ! empty($class_names)) { |
|
636 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
637 | 637 | $msg .= '<ul>'; |
638 | - foreach ( $class_names as $class_name ) { |
|
639 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
638 | + foreach ($class_names as $class_name) { |
|
639 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
640 | 640 | } |
641 | 641 | $msg .= '</ul>'; |
642 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
642 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
643 | 643 | // save list of incompatible addons to wp-options for later use |
644 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
645 | - if ( is_admin() ) { |
|
646 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
644 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
645 | + if (is_admin()) { |
|
646 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
@@ -660,25 +660,25 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @return void |
662 | 662 | */ |
663 | - public function brew_espresso(){ |
|
664 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
663 | + public function brew_espresso() { |
|
664 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
665 | 665 | // load some final core systems |
666 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
667 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
668 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
669 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
670 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
671 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
672 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
673 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
674 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
675 | - |
|
676 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
666 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
667 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
668 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
669 | + add_action('init', array($this, 'load_controllers'), 7); |
|
670 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
671 | + add_action('init', array($this, 'initialize'), 10); |
|
672 | + add_action('init', array($this, 'initialize_last'), 100); |
|
673 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
674 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
675 | + |
|
676 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
677 | 677 | // pew pew pew |
678 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
679 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
678 | + EE_Registry::instance()->load_core('PUE'); |
|
679 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
680 | 680 | } |
681 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
681 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | */ |
693 | 693 | public function set_hooks_for_core() { |
694 | 694 | $this->_deactivate_incompatible_addons(); |
695 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
695 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | |
@@ -701,15 +701,15 @@ discard block |
||
701 | 701 | * Using the information gathered in EE_System::_incompatible_addon_error, |
702 | 702 | * deactivates any addons considered incompatible with the current version of EE |
703 | 703 | */ |
704 | - private function _deactivate_incompatible_addons(){ |
|
705 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
706 | - if ( ! empty( $incompatible_addons )) { |
|
707 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
708 | - foreach ( $active_plugins as $active_plugin ) { |
|
709 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
710 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
711 | - unset( $_GET['activate'] ); |
|
712 | - espresso_deactivate_plugin( $active_plugin ); |
|
704 | + private function _deactivate_incompatible_addons() { |
|
705 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
706 | + if ( ! empty($incompatible_addons)) { |
|
707 | + $active_plugins = get_option('active_plugins', array()); |
|
708 | + foreach ($active_plugins as $active_plugin) { |
|
709 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
710 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
711 | + unset($_GET['activate']); |
|
712 | + espresso_deactivate_plugin($active_plugin); |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | } |
@@ -726,10 +726,10 @@ discard block |
||
726 | 726 | */ |
727 | 727 | public function perform_activations_upgrades_and_migrations() { |
728 | 728 | //first check if we had previously attempted to setup EE's directories but failed |
729 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
729 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
730 | 730 | EEH_Activation::create_upload_directories(); |
731 | 731 | } |
732 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
732 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | |
@@ -741,10 +741,10 @@ discard block |
||
741 | 741 | * @return void |
742 | 742 | */ |
743 | 743 | public function load_CPTs_and_session() { |
744 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
744 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
745 | 745 | // register Custom Post Types |
746 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
747 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
746 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
747 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | |
@@ -759,16 +759,16 @@ discard block |
||
759 | 759 | * @return void |
760 | 760 | */ |
761 | 761 | public function load_controllers() { |
762 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
762 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
763 | 763 | // let's get it started |
764 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
765 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
766 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
767 | - } else if ( ! EE_FRONT_AJAX ) { |
|
768 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
769 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
764 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
765 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
766 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
767 | + } else if ( ! EE_FRONT_AJAX) { |
|
768 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
769 | + EE_Registry::instance()->load_core('Admin'); |
|
770 | 770 | } |
771 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
771 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -782,10 +782,10 @@ discard block |
||
782 | 782 | * @return void |
783 | 783 | */ |
784 | 784 | public function core_loaded_and_ready() { |
785 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
786 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
785 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
786 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
787 | 787 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
788 | - EE_Registry::instance()->load_core( 'Session' ); |
|
788 | + EE_Registry::instance()->load_core('Session'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | * @return void |
800 | 800 | */ |
801 | 801 | public function initialize() { |
802 | - do_action( 'AHEE__EE_System__initialize' ); |
|
802 | + do_action('AHEE__EE_System__initialize'); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * @return void |
814 | 814 | */ |
815 | 815 | public function initialize_last() { |
816 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
816 | + do_action('AHEE__EE_System__initialize_last'); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | |
@@ -845,21 +845,21 @@ discard block |
||
845 | 845 | */ |
846 | 846 | public static function do_not_cache() { |
847 | 847 | // set no cache constants |
848 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
849 | - define( 'DONOTCACHEPAGE', true ); |
|
848 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
849 | + define('DONOTCACHEPAGE', true); |
|
850 | 850 | } |
851 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
852 | - define( 'DONOTCACHCEOBJECT', true ); |
|
851 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
852 | + define('DONOTCACHCEOBJECT', true); |
|
853 | 853 | } |
854 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
855 | - define( 'DONOTCACHEDB', true ); |
|
854 | + if ( ! defined('DONOTCACHEDB')) { |
|
855 | + define('DONOTCACHEDB', true); |
|
856 | 856 | } |
857 | 857 | // add no cache headers |
858 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
858 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
859 | 859 | // plus a little extra for nginx |
860 | - add_filter( 'nocache_headers', array( 'EE_System', 'nocache_headers_nginx' ), 10, 1 ); |
|
860 | + add_filter('nocache_headers', array('EE_System', 'nocache_headers_nginx'), 10, 1); |
|
861 | 861 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
862 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
862 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | * @param $headers |
872 | 872 | * @return array |
873 | 873 | */ |
874 | - public static function nocache_headers_nginx ( $headers ) { |
|
874 | + public static function nocache_headers_nginx($headers) { |
|
875 | 875 | $headers['X-Accel-Expires'] = 0; |
876 | 876 | return $headers; |
877 | 877 | } |
@@ -897,15 +897,15 @@ discard block |
||
897 | 897 | * @param $admin_bar |
898 | 898 | * @return void |
899 | 899 | */ |
900 | - public function espresso_toolbar_items( $admin_bar ) { |
|
900 | + public function espresso_toolbar_items($admin_bar) { |
|
901 | 901 | |
902 | 902 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
903 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
903 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
904 | 904 | return; |
905 | 905 | } |
906 | 906 | |
907 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
908 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
907 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
908 | + EE_Registry::instance()->load_helper('URL'); |
|
909 | 909 | $menu_class = 'espresso_menu_item_class'; |
910 | 910 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
911 | 911 | //because they're only defined in each of their respective constructors |
@@ -917,20 +917,20 @@ discard block |
||
917 | 917 | //Top Level |
918 | 918 | $admin_bar->add_menu(array( |
919 | 919 | 'id' => 'espresso-toolbar', |
920 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
920 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
921 | 921 | 'href' => $events_admin_url, |
922 | 922 | 'meta' => array( |
923 | 923 | 'title' => __('Event Espresso', 'event_espresso'), |
924 | - 'class' => $menu_class . 'first' |
|
924 | + 'class' => $menu_class.'first' |
|
925 | 925 | ), |
926 | 926 | )); |
927 | 927 | |
928 | 928 | //Events |
929 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
929 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
930 | 930 | $admin_bar->add_menu(array( |
931 | 931 | 'id' => 'espresso-toolbar-events', |
932 | 932 | 'parent' => 'espresso-toolbar', |
933 | - 'title' => __( 'Events', 'event_espresso' ), |
|
933 | + 'title' => __('Events', 'event_espresso'), |
|
934 | 934 | 'href' => $events_admin_url, |
935 | 935 | 'meta' => array( |
936 | 936 | 'title' => __('Events', 'event_espresso'), |
@@ -941,13 +941,13 @@ discard block |
||
941 | 941 | } |
942 | 942 | |
943 | 943 | |
944 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
944 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
945 | 945 | //Events Add New |
946 | 946 | $admin_bar->add_menu(array( |
947 | 947 | 'id' => 'espresso-toolbar-events-new', |
948 | 948 | 'parent' => 'espresso-toolbar-events', |
949 | 949 | 'title' => __('Add New', 'event_espresso'), |
950 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
950 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
951 | 951 | 'meta' => array( |
952 | 952 | 'title' => __('Add New', 'event_espresso'), |
953 | 953 | 'target' => '', |
@@ -956,18 +956,18 @@ discard block |
||
956 | 956 | )); |
957 | 957 | } |
958 | 958 | |
959 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
959 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
960 | 960 | |
961 | 961 | //Current post |
962 | 962 | global $post; |
963 | 963 | |
964 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
964 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
965 | 965 | //Events Edit Current Event |
966 | 966 | $admin_bar->add_menu(array( |
967 | 967 | 'id' => 'espresso-toolbar-events-edit', |
968 | 968 | 'parent' => 'espresso-toolbar-events', |
969 | 969 | 'title' => __('Edit Event', 'event_espresso'), |
970 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
970 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
971 | 971 | 'meta' => array( |
972 | 972 | 'title' => __('Edit Event', 'event_espresso'), |
973 | 973 | 'target' => '', |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | } |
980 | 980 | |
981 | 981 | //Events View |
982 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
982 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
983 | 983 | $admin_bar->add_menu(array( |
984 | 984 | 'id' => 'espresso-toolbar-events-view', |
985 | 985 | 'parent' => 'espresso-toolbar-events', |
986 | - 'title' => __( 'View', 'event_espresso' ), |
|
986 | + 'title' => __('View', 'event_espresso'), |
|
987 | 987 | 'href' => $events_admin_url, |
988 | 988 | 'meta' => array( |
989 | 989 | 'title' => __('View', 'event_espresso'), |
@@ -993,12 +993,12 @@ discard block |
||
993 | 993 | )); |
994 | 994 | } |
995 | 995 | |
996 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
996 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
997 | 997 | //Events View All |
998 | 998 | $admin_bar->add_menu(array( |
999 | 999 | 'id' => 'espresso-toolbar-events-all', |
1000 | 1000 | 'parent' => 'espresso-toolbar-events-view', |
1001 | - 'title' => __( 'All', 'event_espresso' ), |
|
1001 | + 'title' => __('All', 'event_espresso'), |
|
1002 | 1002 | 'href' => $events_admin_url, |
1003 | 1003 | 'meta' => array( |
1004 | 1004 | 'title' => __('All', 'event_espresso'), |
@@ -1009,13 +1009,13 @@ discard block |
||
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | |
1012 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1012 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1013 | 1013 | //Events View Today |
1014 | 1014 | $admin_bar->add_menu(array( |
1015 | 1015 | 'id' => 'espresso-toolbar-events-today', |
1016 | 1016 | 'parent' => 'espresso-toolbar-events-view', |
1017 | 1017 | 'title' => __('Today', 'event_espresso'), |
1018 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1018 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1019 | 1019 | 'meta' => array( |
1020 | 1020 | 'title' => __('Today', 'event_espresso'), |
1021 | 1021 | 'target' => '', |
@@ -1025,13 +1025,13 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
1028 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1028 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1029 | 1029 | //Events View This Month |
1030 | 1030 | $admin_bar->add_menu(array( |
1031 | 1031 | 'id' => 'espresso-toolbar-events-month', |
1032 | 1032 | 'parent' => 'espresso-toolbar-events-view', |
1033 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1034 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1033 | + 'title' => __('This Month', 'event_espresso'), |
|
1034 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1035 | 1035 | 'meta' => array( |
1036 | 1036 | 'title' => __('This Month', 'event_espresso'), |
1037 | 1037 | 'target' => '', |
@@ -1041,11 +1041,11 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | //Registration Overview |
1044 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1044 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1045 | 1045 | $admin_bar->add_menu(array( |
1046 | 1046 | 'id' => 'espresso-toolbar-registrations', |
1047 | 1047 | 'parent' => 'espresso-toolbar', |
1048 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1048 | + 'title' => __('Registrations', 'event_espresso'), |
|
1049 | 1049 | 'href' => $reg_admin_url, |
1050 | 1050 | 'meta' => array( |
1051 | 1051 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1056,12 +1056,12 @@ discard block |
||
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | //Registration Overview Today |
1059 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1059 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1060 | 1060 | $admin_bar->add_menu(array( |
1061 | 1061 | 'id' => 'espresso-toolbar-registrations-today', |
1062 | 1062 | 'parent' => 'espresso-toolbar-registrations', |
1063 | - 'title' => __( 'Today', 'event_espresso'), |
|
1064 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1063 | + 'title' => __('Today', 'event_espresso'), |
|
1064 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1065 | 1065 | 'meta' => array( |
1066 | 1066 | 'title' => __('Today', 'event_espresso'), |
1067 | 1067 | 'target' => '', |
@@ -1071,14 +1071,14 @@ discard block |
||
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //Registration Overview Today Completed |
1074 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1074 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1075 | 1075 | $admin_bar->add_menu(array( |
1076 | 1076 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1077 | 1077 | 'parent' => 'espresso-toolbar-registrations-today', |
1078 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1079 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1078 | + 'title' => __('Approved', 'event_espresso'), |
|
1079 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1080 | 1080 | 'meta' => array( |
1081 | - 'title' => __('Approved', 'event_espresso' ), |
|
1081 | + 'title' => __('Approved', 'event_espresso'), |
|
1082 | 1082 | 'target' => '', |
1083 | 1083 | 'class' => $menu_class |
1084 | 1084 | ), |
@@ -1086,14 +1086,14 @@ discard block |
||
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | //Registration Overview Today Pending\ |
1089 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1089 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1090 | 1090 | $admin_bar->add_menu(array( |
1091 | 1091 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1092 | 1092 | 'parent' => 'espresso-toolbar-registrations-today', |
1093 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1094 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1093 | + 'title' => __('Pending', 'event_espresso'), |
|
1094 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1095 | 1095 | 'meta' => array( |
1096 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1096 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1097 | 1097 | 'target' => '', |
1098 | 1098 | 'class' => $menu_class |
1099 | 1099 | ), |
@@ -1101,14 +1101,14 @@ discard block |
||
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | //Registration Overview Today Incomplete |
1104 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1104 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1105 | 1105 | $admin_bar->add_menu(array( |
1106 | 1106 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1107 | 1107 | 'parent' => 'espresso-toolbar-registrations-today', |
1108 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1109 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1108 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1109 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1110 | 1110 | 'meta' => array( |
1111 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1111 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1112 | 1112 | 'target' => '', |
1113 | 1113 | 'class' => $menu_class |
1114 | 1114 | ), |
@@ -1116,12 +1116,12 @@ discard block |
||
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | //Registration Overview Today Incomplete |
1119 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1119 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1120 | 1120 | $admin_bar->add_menu(array( |
1121 | 1121 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1122 | 1122 | 'parent' => 'espresso-toolbar-registrations-today', |
1123 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1124 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1123 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1124 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1125 | 1125 | 'meta' => array( |
1126 | 1126 | 'title' => __('Cancelled', 'event_espresso'), |
1127 | 1127 | 'target' => '', |
@@ -1131,12 +1131,12 @@ discard block |
||
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | //Registration Overview This Month |
1134 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1134 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1135 | 1135 | $admin_bar->add_menu(array( |
1136 | 1136 | 'id' => 'espresso-toolbar-registrations-month', |
1137 | 1137 | 'parent' => 'espresso-toolbar-registrations', |
1138 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1139 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1138 | + 'title' => __('This Month', 'event_espresso'), |
|
1139 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1140 | 1140 | 'meta' => array( |
1141 | 1141 | 'title' => __('This Month', 'event_espresso'), |
1142 | 1142 | 'target' => '', |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | //Registration Overview This Month Approved |
1149 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1149 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1150 | 1150 | $admin_bar->add_menu(array( |
1151 | 1151 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1152 | 1152 | 'parent' => 'espresso-toolbar-registrations-month', |
1153 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1154 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1153 | + 'title' => __('Approved', 'event_espresso'), |
|
1154 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1155 | 1155 | 'meta' => array( |
1156 | 1156 | 'title' => __('Approved', 'event_espresso'), |
1157 | 1157 | 'target' => '', |
@@ -1161,12 +1161,12 @@ discard block |
||
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | //Registration Overview This Month Pending |
1164 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1164 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1165 | 1165 | $admin_bar->add_menu(array( |
1166 | 1166 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1167 | 1167 | 'parent' => 'espresso-toolbar-registrations-month', |
1168 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1169 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1168 | + 'title' => __('Pending', 'event_espresso'), |
|
1169 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1170 | 1170 | 'meta' => array( |
1171 | 1171 | 'title' => __('Pending', 'event_espresso'), |
1172 | 1172 | 'target' => '', |
@@ -1176,14 +1176,14 @@ discard block |
||
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | //Registration Overview This Month Not Approved |
1179 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1179 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1180 | 1180 | $admin_bar->add_menu(array( |
1181 | 1181 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1182 | 1182 | 'parent' => 'espresso-toolbar-registrations-month', |
1183 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1184 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1183 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1184 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1185 | 1185 | 'meta' => array( |
1186 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1186 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1187 | 1187 | 'target' => '', |
1188 | 1188 | 'class' => $menu_class |
1189 | 1189 | ), |
@@ -1192,12 +1192,12 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | |
1194 | 1194 | //Registration Overview This Month Cancelled |
1195 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1195 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1196 | 1196 | $admin_bar->add_menu(array( |
1197 | 1197 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1198 | 1198 | 'parent' => 'espresso-toolbar-registrations-month', |
1199 | 1199 | 'title' => __('Cancelled', 'event_espresso'), |
1200 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1200 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1201 | 1201 | 'meta' => array( |
1202 | 1202 | 'title' => __('Cancelled', 'event_espresso'), |
1203 | 1203 | 'target' => '', |
@@ -1207,11 +1207,11 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | //Extensions & Services |
1210 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1210 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1211 | 1211 | $admin_bar->add_menu(array( |
1212 | 1212 | 'id' => 'espresso-toolbar-extensions-and-services', |
1213 | 1213 | 'parent' => 'espresso-toolbar', |
1214 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1214 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1215 | 1215 | 'href' => $extensions_admin_url, |
1216 | 1216 | 'meta' => array( |
1217 | 1217 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1233,8 +1233,8 @@ discard block |
||
1233 | 1233 | * @param array $exclude_array any existing pages being excluded are in this array. |
1234 | 1234 | * @return array |
1235 | 1235 | */ |
1236 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1237 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1236 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1237 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1254,11 +1254,11 @@ discard block |
||
1254 | 1254 | */ |
1255 | 1255 | public function wp_enqueue_scripts() { |
1256 | 1256 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1257 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1257 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1258 | 1258 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1259 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1259 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1260 | 1260 | // register jQuery Validate |
1261 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE ); |
|
1261 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | $this->_shortcodes = array( |
43 | 43 | '[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'), |
44 | 44 | '[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'), |
45 | - '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>' |
|
46 | - . '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
47 | - . '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
48 | - . '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
45 | + '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
46 | + . '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
47 | + . '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
48 | + . '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
49 | 49 | . '</ul>', |
50 | - '[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
50 | + '[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
51 | 51 | . '<ul>' |
52 | - . '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
53 | - . '<li>' . sprintf( __( '%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
54 | - . '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
52 | + . '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
53 | + . '<li>'.sprintf(__('%days_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
54 | + . '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
55 | 55 | '[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'), |
56 | 56 | '[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'), |
57 | 57 | '[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
58 | 58 | '[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
59 | 59 | '[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
60 | - '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
61 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), |
|
60 | + '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
61 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), |
|
64 | 64 | '[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'), |
65 | 65 | '[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'), |
66 | 66 | '[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
@@ -71,54 +71,54 @@ discard block |
||
71 | 71 | '[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'), |
72 | 72 | '[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'), |
73 | 73 | '[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'), |
74 | - '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' . |
|
75 | - '<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
76 | - '<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>', |
|
74 | + '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
75 | + '<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
76 | + '<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>', |
|
77 | 77 | '[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'), |
78 | 78 | '[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'), |
79 | 79 | '[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'), |
80 | 80 | '[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
81 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
81 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - protected function _parser( $shortcode ) { |
|
87 | + protected function _parser($shortcode) { |
|
88 | 88 | |
89 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
89 | + EE_Registry::instance()->load_helper('Template'); |
|
90 | 90 | |
91 | 91 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
92 | 92 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
93 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
93 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
94 | 94 | |
95 | 95 | //payment |
96 | 96 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
97 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
97 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
98 | 98 | |
99 | 99 | |
100 | - if ( ! $transaction instanceof EE_Transaction ) |
|
100 | + if ( ! $transaction instanceof EE_Transaction) |
|
101 | 101 | return ''; |
102 | 102 | |
103 | - switch ( $shortcode ) { |
|
103 | + switch ($shortcode) { |
|
104 | 104 | case '[TXN_ID]' : |
105 | 105 | return $transaction->ID(); |
106 | 106 | break; |
107 | 107 | |
108 | 108 | case '[PAYMENT_URL]' : |
109 | 109 | $payment_url = $transaction->payment_overview_url(); |
110 | - return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
110 | + return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
111 | 111 | break; |
112 | 112 | |
113 | 113 | case '[INVOICE_LINK]' : |
114 | 114 | $invoice_url = $transaction->invoice_url(); |
115 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
116 | - return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' ); |
|
115 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
116 | + return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
117 | 117 | break; /**/ |
118 | 118 | |
119 | 119 | case '[INVOICE_URL]' : |
120 | 120 | $invoice_url = $transaction->invoice_url(); |
121 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
121 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | case '[INVOICE_LOGO_URL]' : |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | break; |
127 | 127 | |
128 | 128 | case '[INVOICE_LOGO]' : |
129 | - return $this->_get_invoice_logo( TRUE ); |
|
129 | + return $this->_get_invoice_logo(TRUE); |
|
130 | 130 | break; |
131 | 131 | |
132 | 132 | case '[INVOICE_PAYEE_NAME]' : |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | |
149 | 149 | case "[TOTAL_COST]" : |
150 | 150 | $total = $transaction->total(); |
151 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
151 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | case "[PAYMENT_STATUS]" : |
155 | 155 | $status = $transaction->pretty_status(); |
156 | - return !empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
156 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
157 | 157 | break; /**/ |
158 | 158 | |
159 | 159 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
160 | 160 | case "[TXN_STATUS]" : |
161 | 161 | $status = $transaction->pretty_status(); |
162 | - return !empty( $status ) ? $status : __('Unknown', 'event_espresso'); |
|
162 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
163 | 163 | break; |
164 | 164 | |
165 | 165 | case "[TXN_STATUS_ID]" : |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | break; |
168 | 168 | |
169 | 169 | case "[PAYMENT_GATEWAY]" : |
170 | - return $this->_get_payment_gateway( $transaction ); |
|
170 | + return $this->_get_payment_gateway($transaction); |
|
171 | 171 | break; |
172 | 172 | |
173 | 173 | case "[AMOUNT_PAID]" : |
174 | 174 | $amount = $payment instanceof EE_Payment ? $payment->amount() : 0; |
175 | - return EEH_Template::format_currency( $amount ); |
|
175 | + return EEH_Template::format_currency($amount); |
|
176 | 176 | break; |
177 | 177 | |
178 | 178 | case "[TOTAL_AMOUNT_PAID]" : |
179 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
179 | + return EEH_Template::format_currency($transaction->paid()); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case "[TOTAL_OWING]" : |
183 | 183 | $total_owing = $transaction->remaining(); |
184 | - return EEH_Template::format_currency( $total_owing ); |
|
184 | + return EEH_Template::format_currency($total_owing); |
|
185 | 185 | break; |
186 | 186 | |
187 | 187 | case "[TXN_SUBTOTAL]" : |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | break; |
190 | 190 | |
191 | 191 | case "[TXN_TAX_SUBTOTAL]" : |
192 | - return EEH_Template::format_currency($this->_get_subtotal( TRUE )); |
|
192 | + return EEH_Template::format_currency($this->_get_subtotal(TRUE)); |
|
193 | 193 | break; |
194 | 194 | |
195 | 195 | case "[TKT_QTY_PURCHASED]" : |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | break; |
199 | 199 | |
200 | 200 | case "[TRANSACTION_ADMIN_URL]" : |
201 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
202 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
203 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') ); |
|
201 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
202 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
203 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
204 | 204 | return $url; |
205 | 205 | break; |
206 | 206 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | //get primary_registration |
209 | 209 | $reg = $this->_data->primary_reg_obj; |
210 | 210 | |
211 | - if ( ! $reg instanceof EE_Registration ) { |
|
211 | + if ( ! $reg instanceof EE_Registration) { |
|
212 | 212 | return ''; |
213 | 213 | } |
214 | 214 | return $reg->receipt_url(); |
215 | 215 | break; |
216 | 216 | |
217 | 217 | case "[INVOICE_RECEIPT_SWITCHER_URL]" : |
218 | - return $this->_get_invoice_receipt_switcher( FALSE ); |
|
218 | + return $this->_get_invoice_receipt_switcher(FALSE); |
|
219 | 219 | break; |
220 | 220 | |
221 | 221 | case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" : |
@@ -225,20 +225,20 @@ discard block |
||
225 | 225 | |
226 | 226 | } |
227 | 227 | |
228 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) { |
|
229 | - return $this->_get_custom_total_oweing( $shortcode ); |
|
228 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) { |
|
229 | + return $this->_get_custom_total_oweing($shortcode); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) { |
|
233 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
232 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) { |
|
233 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) { |
|
237 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
236 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) { |
|
237 | + return $this->_get_payment_link_if_needed($shortcode); |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
241 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
240 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
241 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return ''; |
@@ -255,22 +255,22 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return string parsed. |
257 | 257 | */ |
258 | - private function _get_custom_total_oweing( $shortcode ) { |
|
259 | - $valid_shortcodes = array( 'transaction' ); |
|
260 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
258 | + private function _get_custom_total_oweing($shortcode) { |
|
259 | + $valid_shortcodes = array('transaction'); |
|
260 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
261 | 261 | |
262 | 262 | //ensure default is set. |
263 | 263 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
264 | 264 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
265 | 265 | |
266 | - if ( $total_owing > 0 ) { |
|
267 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
266 | + if ($total_owing > 0) { |
|
267 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
268 | 268 | |
269 | 269 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
270 | 270 | $this->_set_shortcode_helper(); |
271 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
271 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
272 | 272 | } else { |
273 | - $owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
273 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return $owing_content; |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | |
279 | 279 | |
280 | 280 | |
281 | - private function _get_payment_gateway( $transaction ) { |
|
282 | - $pm = $this->_get_payment_method( $transaction ); |
|
281 | + private function _get_payment_gateway($transaction) { |
|
282 | + $pm = $this->_get_payment_method($transaction); |
|
283 | 283 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
284 | 284 | } |
285 | 285 | |
@@ -294,37 +294,37 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return string url or html |
296 | 296 | */ |
297 | - private function _get_invoice_logo( $img_tags = FALSE ) { |
|
297 | + private function _get_invoice_logo($img_tags = FALSE) { |
|
298 | 298 | //try to get the invoice payment method's logo for this transaction image first |
299 | 299 | $pm = $this->_get_payment_method(); |
300 | - if ( $pm instanceof EE_Payment_Method ){ |
|
301 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE ); |
|
302 | - }else{ |
|
300 | + if ($pm instanceof EE_Payment_Method) { |
|
301 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE); |
|
302 | + } else { |
|
303 | 303 | $invoice_logo_url = NULL; |
304 | 304 | } |
305 | - if( empty( $invoice_logo_url ) ){ |
|
305 | + if (empty($invoice_logo_url)) { |
|
306 | 306 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
307 | 307 | } |
308 | 308 | |
309 | - if ( empty( $invoice_logo_url ) ) { |
|
309 | + if (empty($invoice_logo_url)) { |
|
310 | 310 | return ''; |
311 | 311 | } |
312 | 312 | |
313 | - if ( ! $img_tags ) { |
|
313 | + if ( ! $img_tags) { |
|
314 | 314 | return $invoice_logo_url; |
315 | 315 | } |
316 | 316 | |
317 | 317 | //image tags have been requested. |
318 | - $image_size = getimagesize( $invoice_logo_url ); |
|
318 | + $image_size = getimagesize($invoice_logo_url); |
|
319 | 319 | |
320 | 320 | //if image is wider than 200px, set the wideth to 200 |
321 | - if ( $image_size[0] > 300 ) { |
|
321 | + if ($image_size[0] > 300) { |
|
322 | 322 | $image_width = 300; |
323 | - }else{ |
|
323 | + } else { |
|
324 | 324 | $image_width = $image_size[0]; |
325 | 325 | } |
326 | 326 | |
327 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
327 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -341,26 +341,26 @@ discard block |
||
341 | 341 | private function _get_invoice_payee_name() { |
342 | 342 | $payee_name = NULL; |
343 | 343 | $pm = $this->_get_payment_method(); |
344 | - if( $pm instanceof EE_Payment_Method ){ |
|
345 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE ); |
|
344 | + if ($pm instanceof EE_Payment_Method) { |
|
345 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE); |
|
346 | 346 | } |
347 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
347 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
348 | 348 | return $payee_name; |
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * gets the payment method for this transaction. Otherwise gets a default one. |
353 | 353 | */ |
354 | - private function _get_payment_method( $transaction = null ){ |
|
355 | - if( $transaction instanceof EE_Transaction ) { |
|
354 | + private function _get_payment_method($transaction = null) { |
|
355 | + if ($transaction instanceof EE_Transaction) { |
|
356 | 356 | $payment_method = $transaction->payment_method(); |
357 | - if ( empty( $payment_method ) ) { |
|
358 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
357 | + if (empty($payment_method)) { |
|
358 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
359 | 359 | } |
360 | 360 | return $payment_method; |
361 | - }else{ |
|
361 | + } else { |
|
362 | 362 | //get the first payment method we can find |
363 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
363 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | private function _get_invoice_payee_email() { |
378 | 378 | $payee_email = NULL; |
379 | 379 | $pm = $this->_get_payment_method(); |
380 | - if( $pm instanceof EE_Payment_Method ){ |
|
381 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE ); |
|
380 | + if ($pm instanceof EE_Payment_Method) { |
|
381 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE); |
|
382 | 382 | } |
383 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
383 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
384 | 384 | return $payee_email; |
385 | 385 | } |
386 | 386 | |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string |
398 | 398 | */ |
399 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
399 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
400 | 400 | $payee_tax_number = NULL; |
401 | 401 | $pm = $this->_get_payment_method(); |
402 | - if( $pm instanceof EE_Payment_Method ){ |
|
403 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE ); |
|
402 | + if ($pm instanceof EE_Payment_Method) { |
|
403 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE); |
|
404 | 404 | } |
405 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
405 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
406 | 406 | |
407 | - if ( empty( $payee_tax_number ) ) { |
|
407 | + if (empty($payee_tax_number)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | 411 | //any attributes? |
412 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
412 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
413 | 413 | |
414 | 414 | //prefix? |
415 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' ); |
|
416 | - return $prefix . $payee_tax_number; |
|
415 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
416 | + return $prefix.$payee_tax_number; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -430,22 +430,22 @@ discard block |
||
430 | 430 | private function _get_invoice_payee_address() { |
431 | 431 | $payee_address = NULL; |
432 | 432 | $pm = $this->_get_payment_method(); |
433 | - if( $pm instanceof EE_Payment_Method ){ |
|
434 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE ); |
|
433 | + if ($pm instanceof EE_Payment_Method) { |
|
434 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE); |
|
435 | 435 | } |
436 | - if ( empty( $payee_address ) ) { |
|
436 | + if (empty($payee_address)) { |
|
437 | 437 | $organization = EE_Registry::instance()->CFG->organization; |
438 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
439 | - $payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
440 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
438 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
439 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
440 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
441 | 441 | |
442 | 442 | //state |
443 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
444 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
443 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
444 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
445 | 445 | |
446 | 446 | //Country |
447 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
448 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
447 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
448 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
449 | 449 | } |
450 | 450 | return $payee_address; |
451 | 451 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | private function _get_invoice_payment_instructions() { |
464 | 464 | $instructions = NULL; |
465 | 465 | $pm = $this->_get_payment_method(); |
466 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : ''; |
|
466 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : ''; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -477,27 +477,27 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - protected function _get_invoice_receipt_switcher( $button = TRUE ) { |
|
480 | + protected function _get_invoice_receipt_switcher($button = TRUE) { |
|
481 | 481 | $reg = $this->_data->primary_reg_obj; |
482 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
483 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
482 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
483 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
484 | 484 | return''; |
485 | 485 | } |
486 | 486 | |
487 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
488 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' ); |
|
489 | - $switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
487 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
488 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso'); |
|
489 | + $switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
490 | 490 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
491 | 491 | |
492 | - if ( ! $button ) { |
|
492 | + if ( ! $button) { |
|
493 | 493 | return $switch_to_url; |
494 | 494 | } |
495 | 495 | |
496 | - if ( ! empty( $switch_to_url ) ) { |
|
496 | + if ( ! empty($switch_to_url)) { |
|
497 | 497 | |
498 | 498 | return ' |
499 | -<form method="post" action="' . $switch_to_url . '" > |
|
500 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
499 | +<form method="post" action="' . $switch_to_url.'" > |
|
500 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
501 | 501 | </form> |
502 | 502 | '; |
503 | 503 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - private function _get_receipt_url( EE_Transaction $transaction ) { |
|
520 | + private function _get_receipt_url(EE_Transaction $transaction) { |
|
521 | 521 | //get primary_registration |
522 | 522 | $reg = $this->_data->primary_reg_obj; |
523 | 523 | |
524 | - if ( ! $reg instanceof EE_Registration ) { |
|
524 | + if ( ! $reg instanceof EE_Registration) { |
|
525 | 525 | return ''; |
526 | 526 | } |
527 | 527 | |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return int |
539 | 539 | */ |
540 | - private function _get_subtotal( $tax = FALSE ) { |
|
541 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL; |
|
540 | + private function _get_subtotal($tax = FALSE) { |
|
541 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL; |
|
542 | 542 | |
543 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
543 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
544 | 544 | return 0; |
545 | 545 | } |
546 | 546 | |
@@ -559,27 +559,27 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return string parsed. |
561 | 561 | */ |
562 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
563 | - $valid_shortcodes = array( 'transaction' ); |
|
564 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
562 | + private function _get_payment_link_if_needed($shortcode) { |
|
563 | + $valid_shortcodes = array('transaction'); |
|
564 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
565 | 565 | |
566 | 566 | //ensure default is set. |
567 | 567 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
568 | 568 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
569 | 569 | |
570 | - if ( $total_owing > 0 ) { |
|
571 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
572 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
573 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
574 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
575 | - $opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
576 | - $opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag; |
|
577 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
578 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
570 | + if ($total_owing > 0) { |
|
571 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
572 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
573 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
574 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
575 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
576 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
577 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
578 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
579 | 579 | |
580 | 580 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
581 | 581 | $this->_set_shortcode_helper(); |
582 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID ); |
|
582 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID); |
|
583 | 583 | } else { |
584 | 584 | return ''; |
585 | 585 | } |
@@ -599,31 +599,31 @@ discard block |
||
599 | 599 | * @param EE_Transaction $transaction |
600 | 600 | * @return string |
601 | 601 | */ |
602 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
602 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
603 | 603 | //if transaction is paid in full then we can just return an empty string |
604 | - if ( $transaction->remaining() === 0 ) { |
|
604 | + if ($transaction->remaining() === 0) { |
|
605 | 605 | return ''; |
606 | 606 | } |
607 | 607 | |
608 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
609 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
610 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
611 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' ); |
|
612 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
608 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
609 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
610 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
611 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso'); |
|
612 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
613 | 613 | |
614 | 614 | //setup date due: |
615 | 615 | try { |
616 | - if ( $transaction_created instanceof DateTime ) { |
|
617 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
616 | + if ($transaction_created instanceof DateTime) { |
|
617 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
618 | 618 | } else { |
619 | 619 | throw new Exception(); |
620 | 620 | } |
621 | - } catch( Exception $e ) { |
|
621 | + } catch (Exception $e) { |
|
622 | 622 | //format was likely invalid. |
623 | 623 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
624 | 624 | } |
625 | 625 | |
626 | - return $prefix_text . $date_due; |
|
626 | + return $prefix_text.$date_due; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | } //end EE_Transaction Shortcodes library |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @return EED_Core_Rest_Api |
23 | 23 | */ |
24 | 24 | public static function instance() { |
25 | - return parent::get_instance( __CLASS__ ); |
|
25 | + return parent::get_instance(__CLASS__); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | |
54 | 54 | public static function set_hooks_both() { |
55 | - add_action( 'rest_api_init', array( 'EED_Core_REST_API', 'register_routes' ) ); |
|
56 | - add_filter( 'rest_route_data', array( 'EED_Core_REST_API', 'hide_old_endpoints' ), 10, 2 ); |
|
57 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
55 | + add_action('rest_api_init', array('EED_Core_REST_API', 'register_routes')); |
|
56 | + add_filter('rest_route_data', array('EED_Core_REST_API', 'hide_old_endpoints'), 10, 2); |
|
57 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
64 | 64 | */ |
65 | 65 | public static function register_routes() { |
66 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
67 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
68 | - foreach( $routes as $route ) { |
|
66 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
67 | + foreach ($relative_urls as $endpoint => $routes) { |
|
68 | + foreach ($routes as $route) { |
|
69 | 69 | register_rest_route( |
70 | 70 | $namespace, |
71 | 71 | $endpoint, |
72 | 72 | array( |
73 | - 'callback' => $route[ 'callback' ], |
|
74 | - 'methods' => $route[ 'methods' ], |
|
75 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
73 | + 'callback' => $route['callback'], |
|
74 | + 'methods' => $route['methods'], |
|
75 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
76 | 76 | ) |
77 | 77 | ); |
78 | 78 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * } |
90 | 90 | */ |
91 | 91 | public static function get_ee_route_data() { |
92 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
93 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
92 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
93 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
94 | 94 | self::save_ee_routes(); |
95 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
95 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
96 | 96 | } |
97 | 97 | return $ee_routes; |
98 | 98 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @return void |
104 | 104 | */ |
105 | 105 | public static function save_ee_routes() { |
106 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
106 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
107 | 107 | $instance = self::instance(); |
108 | 108 | $routes = array_replace_recursive( |
109 | 109 | $instance->_register_config_routes(), |
110 | 110 | $instance->_register_meta_routes(), |
111 | 111 | $instance->_register_model_routes() |
112 | 112 | ); |
113 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
113 | + update_option(self::saved_routes_option_names, $routes, true); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return array @see get_ee_route_data |
120 | 120 | */ |
121 | 121 | protected function _register_model_routes() { |
122 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
122 | + EE_Registry::instance()->load_helper('Inflector'); |
|
123 | 123 | $models_to_register = apply_filters( |
124 | 124 | 'FHEE__EED_Core_REST_API___register_model_routes', |
125 | 125 | EE_Registry::instance()->non_abstract_db_models |
@@ -128,23 +128,23 @@ discard block |
||
128 | 128 | unset($models_to_register['Extra_Meta']); |
129 | 129 | unset($models_to_register['Extra_Join']); |
130 | 130 | $model_routes = array( ); |
131 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
131 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
132 | 132 | |
133 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
133 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
134 | 134 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
135 | - $ee_namespace = self::ee_api_namespace . $version; |
|
136 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
137 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
138 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
135 | + $ee_namespace = self::ee_api_namespace.$version; |
|
136 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
137 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
138 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
139 | 139 | array( |
140 | 140 | 'callback' => array( |
141 | 141 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
142 | 142 | 'handle_request_get_all' ), |
143 | 143 | 'methods' => WP_REST_Server::READABLE, |
144 | 144 | 'hidden_endpoint' => $hidden_endpoint, |
145 | - 'args' => $this->_get_read_query_params( $model_name ), |
|
145 | + 'args' => $this->_get_read_query_params($model_name), |
|
146 | 146 | '_links' => array( |
147 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
147 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
148 | 148 | ) |
149 | 149 | ), |
150 | 150 | // array( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | // 'hidden_endpoint' => $hidden_endpoint |
156 | 156 | // ) |
157 | 157 | ); |
158 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
158 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
159 | 159 | array( |
160 | 160 | 'callback' => array( |
161 | 161 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'include' => array( |
167 | 167 | 'required' => false, |
168 | 168 | 'default' => '*', |
169 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
169 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
170 | 170 | ), |
171 | 171 | ) |
172 | 172 | ), |
@@ -179,20 +179,20 @@ discard block |
||
179 | 179 | // ), |
180 | 180 | ); |
181 | 181 | //@todo: also handle DELETE for a single item |
182 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
183 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
182 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
183 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
184 | 184 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
185 | 185 | $relation_name, |
186 | 186 | $relation_obj |
187 | 187 | ); |
188 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
188 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
189 | 189 | array( |
190 | 190 | 'callback' => array( |
191 | 191 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
192 | 192 | 'handle_request_get_related' ), |
193 | 193 | 'methods' => WP_REST_Server::READABLE, |
194 | 194 | 'hidden_endpoint' => $hidden_endpoint, |
195 | - 'args' => $this->_get_read_query_params( $relation_name ), |
|
195 | + 'args' => $this->_get_read_query_params($relation_name), |
|
196 | 196 | ), |
197 | 197 | // array( |
198 | 198 | // 'callback' => array( |
@@ -215,47 +215,47 @@ discard block |
||
215 | 215 | * @param string $model_name eg 'Event' or 'Venue' |
216 | 216 | * @return array describing the args acceptable when querying this model |
217 | 217 | */ |
218 | - protected function _get_read_query_params( $model_name ) { |
|
219 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
218 | + protected function _get_read_query_params($model_name) { |
|
219 | + $model = EE_Registry::instance()->load_model($model_name); |
|
220 | 220 | $default_orderby = array(); |
221 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
222 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
221 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
222 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
223 | 223 | } |
224 | 224 | return array( |
225 | 225 | 'where' => array( |
226 | 226 | 'required' => false, |
227 | 227 | 'default' => array(), |
228 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterwhere for documentation', 'event_espresso' ), |
|
228 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterwhere for documentation', 'event_espresso'), |
|
229 | 229 | ), |
230 | 230 | 'limit' => array( |
231 | 231 | 'required' => false, |
232 | 232 | 'default' => 50, |
233 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterlimit for documentation', 'event_espresso' ) |
|
233 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterlimit for documentation', 'event_espresso') |
|
234 | 234 | ), |
235 | 235 | 'order_by' => array( |
236 | 236 | 'required' => false, |
237 | 237 | 'default' => $default_orderby, |
238 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterorder_by for documentation', 'event_espresso' ) |
|
238 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterorder_by for documentation', 'event_espresso') |
|
239 | 239 | ), |
240 | 240 | 'group_by' => array( |
241 | 241 | 'required' => false, |
242 | 242 | 'default' => null, |
243 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtergroup_by for documentation', 'event_espresso' ) |
|
243 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtergroup_by for documentation', 'event_espresso') |
|
244 | 244 | ), |
245 | 245 | 'having' => array( |
246 | 246 | 'required' => false, |
247 | 247 | 'default' => null, |
248 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterhaving for documentation', 'event_espresso' ) |
|
248 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterhaving for documentation', 'event_espresso') |
|
249 | 249 | ), |
250 | 250 | 'caps' => array( |
251 | 251 | 'required' => false, |
252 | 252 | 'default' => EEM_Base::caps_read, |
253 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtercaps for documentation', 'event_espresso' ) |
|
253 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtercaps for documentation', 'event_espresso') |
|
254 | 254 | ), |
255 | 255 | 'include' => array( |
256 | 256 | 'required' => false, |
257 | 257 | 'default' => '*', |
258 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
258 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
259 | 259 | ), |
260 | 260 | ); |
261 | 261 | } |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | */ |
267 | 267 | protected function _register_config_routes() { |
268 | 268 | $config_routes = array(); |
269 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
270 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
269 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
270 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
271 | 271 | array( |
272 | 272 | 'callback' => array( |
273 | 273 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | */ |
287 | 287 | protected function _register_meta_routes() { |
288 | 288 | $meta_routes = array(); |
289 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
290 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
289 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
290 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
291 | 291 | array( |
292 | 292 | 'callback' => array( |
293 | 293 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | * @param array $route_data |
309 | 309 | * @return array |
310 | 310 | */ |
311 | - public function hide_old_endpoints( $route_data ) { |
|
312 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
313 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
314 | - foreach( $routes as $route ) { |
|
315 | - if( $route[ 'hidden_endpoint' ] ) { |
|
316 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
317 | - unset( $route_data[ $full_route ] ); |
|
311 | + public function hide_old_endpoints($route_data) { |
|
312 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
313 | + foreach ($relative_urls as $endpoint => $routes) { |
|
314 | + foreach ($routes as $route) { |
|
315 | + if ($route['hidden_endpoint']) { |
|
316 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
317 | + unset($route_data[$full_route]); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @return array |
335 | 335 | */ |
336 | 336 | public static function version_compatibilities() { |
337 | - return apply_filters( 'FHEE__EED_Core_REST_API__version_compatibilities', array( '4.8.29' => '4.8.29' ) ); |
|
337 | + return apply_filters('FHEE__EED_Core_REST_API__version_compatibilities', array('4.8.29' => '4.8.29')); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -348,17 +348,17 @@ discard block |
||
348 | 348 | public static function versions_served() { |
349 | 349 | $version_compatibilities = EED_Core_Rest_Api::version_compatibilities(); |
350 | 350 | $versions_served = array(); |
351 | - $lowest_compatible_version = $version_compatibilities[ EED_Core_Rest_Api::core_version() ]; |
|
351 | + $lowest_compatible_version = $version_compatibilities[EED_Core_Rest_Api::core_version()]; |
|
352 | 352 | //for each version of core we have ever served: |
353 | - foreach( array_keys( EED_Core_Rest_Api::version_compatibilities() ) as $possibly_served_version ) { |
|
353 | + foreach (array_keys(EED_Core_Rest_Api::version_compatibilities()) as $possibly_served_version) { |
|
354 | 354 | //if it's not above the current core version, and it's compatible with the current version of core |
355 | - if( |
|
355 | + if ( |
|
356 | 356 | $possibly_served_version < EED_Core_Rest_Api::core_version() |
357 | 357 | && $possibly_served_version >= $lowest_compatible_version |
358 | 358 | ) { |
359 | - $versions_served[ $possibly_served_version ] = true; |
|
360 | - }else { |
|
361 | - $versions_served[ $possibly_served_version ] = false; |
|
359 | + $versions_served[$possibly_served_version] = true; |
|
360 | + } else { |
|
361 | + $versions_served[$possibly_served_version] = false; |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | return $versions_served; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return string |
372 | 372 | */ |
373 | 373 | public static function core_version() { |
374 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
374 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param WP $WP |
384 | 384 | * @return void |
385 | 385 | */ |
386 | - public function run( $WP ) { |
|
386 | + public function run($WP) { |
|
387 | 387 | |
388 | 388 | } |
389 | 389 |
@@ -1,35 +1,35 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.2 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EE_Gateway |
|
17 | - * |
|
18 | - * Abstract base class for all gateways |
|
19 | - * |
|
20 | - * @package Event Espresso |
|
21 | - * @subpackage core/libraries/payment_methods |
|
22 | - * @author Mike Nelson |
|
23 | - * |
|
24 | - * ------------------------------------------------------------------------ |
|
25 | - * Class for processing payments. This has been designed in a way so that other WP Plugins |
|
26 | - * can use this class for processing payments, and theoreitcally any of its children, provided they implement the |
|
27 | - * interfaces it uses. |
|
28 | - * The necessary interfaces to be implemented are contained in core/libaries/payment_methods/EEI_Payment_Method_Interfaces.php and |
|
29 | - * EEI_Interfaces. After constructing a gateway object, you need to set all the properties which reference many of the |
|
30 | - * needed helpers and models (see all the methods starting with "set_", eg seg_line_item_helper which should be passed an object |
|
31 | - * which implements EEHI_Line_Item_Helper; etc). |
|
32 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.2 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EE_Gateway |
|
17 | + * |
|
18 | + * Abstract base class for all gateways |
|
19 | + * |
|
20 | + * @package Event Espresso |
|
21 | + * @subpackage core/libraries/payment_methods |
|
22 | + * @author Mike Nelson |
|
23 | + * |
|
24 | + * ------------------------------------------------------------------------ |
|
25 | + * Class for processing payments. This has been designed in a way so that other WP Plugins |
|
26 | + * can use this class for processing payments, and theoreitcally any of its children, provided they implement the |
|
27 | + * interfaces it uses. |
|
28 | + * The necessary interfaces to be implemented are contained in core/libaries/payment_methods/EEI_Payment_Method_Interfaces.php and |
|
29 | + * EEI_Interfaces. After constructing a gateway object, you need to set all the properties which reference many of the |
|
30 | + * needed helpers and models (see all the methods starting with "set_", eg seg_line_item_helper which should be passed an object |
|
31 | + * which implements EEHI_Line_Item_Helper; etc). |
|
32 | + */ |
|
33 | 33 | abstract class EE_Gateway{ |
34 | 34 | /** |
35 | 35 | * a constant used as a possible value for $_currencies_supported to indicate |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Ticket','event_espresso'); |
|
40 | - $this->plural_item = __('Tickets','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
40 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Ticket'=>array( |
47 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
48 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
47 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
48 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
49 | 49 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
50 | - 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
51 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
52 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
53 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
54 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ), |
|
50 | + 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
51 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
54 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF), |
|
55 | 55 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
56 | 56 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
57 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF), |
|
58 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ), |
|
59 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
60 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
61 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
57 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF), |
|
58 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF), |
|
59 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
60 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
61 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
62 | 62 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
63 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
63 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
64 | 64 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
65 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
66 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
65 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
66 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
67 | 67 | )); |
68 | 68 | $this->_model_relations = array( |
69 | 69 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | //this model is generally available for reading |
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
78 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
79 | 79 | //account for default tickets in the caps |
80 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
81 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
82 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
83 | - parent::__construct( $timezone ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
81 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
82 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
83 | + parent::__construct($timezone); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_all_default_tickets() { |
93 | 93 | /** @type EE_Ticket[] $tickets */ |
94 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) ); |
|
94 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
95 | 95 | //we need to set the start date and end date to today's date and the start of the default dtt |
96 | - return $this->_set_default_dates( $tickets ); |
|
96 | + return $this->_set_default_dates($tickets); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @param EE_Ticket[] $tickets |
104 | 104 | * @return EE_Ticket[] |
105 | 105 | */ |
106 | - private function _set_default_dates( $tickets ) { |
|
107 | - foreach ( $tickets as $ticket ) { |
|
108 | - $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true) ); |
|
109 | - $ticket->set('TKT_end_date', $this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) ); |
|
110 | - $ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) ); |
|
106 | + private function _set_default_dates($tickets) { |
|
107 | + foreach ($tickets as $ticket) { |
|
108 | + $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true)); |
|
109 | + $ticket->set('TKT_end_date', $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30)); |
|
110 | + $ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $tickets; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param array $query_params |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
126 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params ); |
|
125 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
126 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param EE_Ticket[] $tickets |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function update_tickets_sold($tickets){ |
|
137 | - foreach($tickets as $ticket){ |
|
136 | + public function update_tickets_sold($tickets) { |
|
137 | + foreach ($tickets as $ticket) { |
|
138 | 138 | /* @var $ticket EE_Ticket */ |
139 | 139 | $ticket->update_tickets_sold(); |
140 | 140 | } |
@@ -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 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
61 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
62 | 62 | |
63 | 63 | //if we were going to add our own metaboxes we'd use the below. |
64 | 64 | $this->_metaboxes = array( |
65 | 65 | 0 => array( |
66 | - 'page_route' => array('edit','create_new'), |
|
66 | + 'page_route' => array('edit', 'create_new'), |
|
67 | 67 | 'func' => 'pricing_metabox', |
68 | 68 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
69 | 69 | 'priority' => 'high', |
70 | 70 | 'context' => 'normal' |
71 | 71 | ), |
72 | 72 | |
73 | - );/**/ |
|
73 | + ); /**/ |
|
74 | 74 | |
75 | 75 | $this->_remove_metaboxes = array( |
76 | 76 | 0 => array( |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @var array Expected an array returned with 'date' and 'time' keys. |
91 | 91 | */ |
92 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
93 | 93 | 'date' => 'Y-m-d', |
94 | 94 | 'time' => 'h:i a' |
95 | 95 | )); |
96 | 96 | |
97 | 97 | //validate |
98 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
99 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
98 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
99 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
100 | 100 | |
101 | 101 | //validate format strings |
102 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
103 | - if ( is_array( $format_validation ) ) { |
|
104 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
105 | - foreach ( $format_validation as $error ) { |
|
106 | - $msg .= '<li>' . $error . '</li>'; |
|
102 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
103 | + if (is_array($format_validation)) { |
|
104 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
105 | + foreach ($format_validation as $error) { |
|
106 | + $msg .= '<li>'.$error.'</li>'; |
|
107 | 107 | } |
108 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
109 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
108 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
109 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | $this->_date_format_strings = array( |
111 | 111 | 'date' => 'Y-m-d', |
112 | 112 | 'time' => 'h:i a' |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | $this->_scripts_styles = array( |
118 | 118 | 'registers' => array( |
119 | 119 | 'ee-tickets-datetimes-css' => array( |
120 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
120 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
121 | 121 | 'type' => 'css' |
122 | 122 | ), |
123 | 123 | 'ee-dtt-ticket-metabox' => array( |
124 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
124 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
125 | 125 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
126 | 126 | ) |
127 | 127 | ), |
128 | 128 | 'deregisters' => array( |
129 | - 'event-editor-css' => array('type' => 'css' ), |
|
129 | + 'event-editor-css' => array('type' => 'css'), |
|
130 | 130 | 'event-datetime-metabox' => array('type' => 'js') |
131 | 131 | ), |
132 | 132 | 'enqueues' => array( |
133 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
134 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
133 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
134 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
135 | 135 | ), |
136 | 136 | 'localize' => array( |
137 | 137 | 'ee-dtt-ticket-metabox' => array( |
138 | 138 | 'DTT_TRASH_BLOCK' => array( |
139 | 139 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
140 | 140 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
141 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
141 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
142 | 142 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | 143 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
144 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
144 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
145 | 145 | ), |
146 | 146 | 'DTT_ERROR_MSG' => array( |
147 | 147 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
148 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
148 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
149 | 149 | ), |
150 | 150 | 'DTT_OVERSELL_WARNING' => array( |
151 | 151 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
152 | 152 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
153 | 153 | ), |
154 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
155 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
154 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
155 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
156 | 156 | ) |
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | 160 | |
161 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
162 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
161 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
162 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - public function caf_updates( $update_callbacks ) { |
|
168 | - foreach ( $update_callbacks as $key => $callback ) { |
|
169 | - if ( $callback[1] == '_default_tickets_update' ) |
|
170 | - unset( $update_callbacks[$key] ); |
|
167 | + public function caf_updates($update_callbacks) { |
|
168 | + foreach ($update_callbacks as $key => $callback) { |
|
169 | + if ($callback[1] == '_default_tickets_update') |
|
170 | + unset($update_callbacks[$key]); |
|
171 | 171 | } |
172 | 172 | |
173 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
173 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
174 | 174 | return $update_callbacks; |
175 | 175 | } |
176 | 176 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $data The request data from the form |
184 | 184 | * @return bool success or fail |
185 | 185 | */ |
186 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
186 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
187 | 187 | //first we need to start with datetimes cause they are the "root" items attached to events. |
188 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
188 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
189 | 189 | //next tackle the tickets (and prices?) |
190 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
190 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,41 +198,41 @@ discard block |
||
198 | 198 | * @param array $data the request data from the form |
199 | 199 | * @return EE_Datetime[] |
200 | 200 | */ |
201 | - protected function _update_dtts( $evt_obj, $data ) { |
|
202 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
201 | + protected function _update_dtts($evt_obj, $data) { |
|
202 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
203 | 203 | $saved_dtt_ids = array(); |
204 | 204 | $saved_dtt_objs = array(); |
205 | 205 | |
206 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
206 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
207 | 207 | //trim all values to ensure any excess whitespace is removed. |
208 | 208 | $dtt = array_map( |
209 | - function( $datetime_data ) { |
|
210 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
209 | + function($datetime_data) { |
|
210 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
211 | 211 | }, |
212 | 212 | $dtt |
213 | 213 | ); |
214 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
215 | 215 | $datetime_values = array( |
216 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
217 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
218 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
216 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
217 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
218 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
219 | 219 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
220 | 220 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
221 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
222 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
221 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
222 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
226 | 226 | |
227 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
228 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
227 | + if ( ! empty($dtt['DTT_ID'])) { |
|
228 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
229 | 229 | |
230 | 230 | //set date and time format according to what is set in this class. |
231 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
232 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
231 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
232 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
233 | 233 | |
234 | - foreach ( $datetime_values as $field => $value ) { |
|
235 | - $DTM->set( $field, $value ); |
|
234 | + foreach ($datetime_values as $field => $value) { |
|
235 | + $DTM->set($field, $value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
241 | 241 | |
242 | 242 | } else { |
243 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
243 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
244 | 244 | |
245 | 245 | //reset date and times to match the format |
246 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
247 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
248 | - foreach( $datetime_values as $field => $value ) { |
|
249 | - $DTM->set( $field, $value ); |
|
246 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
247 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
248 | + foreach ($datetime_values as $field => $value) { |
|
249 | + $DTM->set($field, $value); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | $DTM->save(); |
255 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
255 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
256 | 256 | $evt_obj->save(); |
257 | 257 | |
258 | 258 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
259 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
260 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
259 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
260 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
261 | 261 | EE_Registry::instance()->load_helper('DTT_Helper'); |
262 | 262 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
263 | 263 | $DTM->save(); |
@@ -273,25 +273,25 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
276 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
276 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
277 | 277 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
278 | 278 | |
279 | - if ( is_array( $old_datetimes ) ) { |
|
280 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
281 | - foreach ( $dtts_to_delete as $id ) { |
|
282 | - $id = absint( $id ); |
|
283 | - if ( empty( $id ) ) |
|
279 | + if (is_array($old_datetimes)) { |
|
280 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
281 | + foreach ($dtts_to_delete as $id) { |
|
282 | + $id = absint($id); |
|
283 | + if (empty($id)) |
|
284 | 284 | continue; |
285 | 285 | |
286 | 286 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
287 | 287 | |
288 | 288 | //remove tkt relationships. |
289 | 289 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
290 | - foreach ( $related_tickets as $tkt ) { |
|
290 | + foreach ($related_tickets as $tkt) { |
|
291 | 291 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
292 | 292 | } |
293 | 293 | |
294 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
294 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
295 | 295 | $dtt_to_remove->refresh_cache_of_related_objects(); |
296 | 296 | |
297 | 297 | } |
@@ -312,86 +312,86 @@ discard block |
||
312 | 312 | * @param array $data incoming request data |
313 | 313 | * @return EE_Ticket[] |
314 | 314 | */ |
315 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
315 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
316 | 316 | |
317 | 317 | $new_tkt = null; |
318 | 318 | $new_default = null; |
319 | 319 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
320 | 320 | $data = stripslashes_deep($data); |
321 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
321 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
322 | 322 | $saved_tickets = $dtts_on_existing = array(); |
323 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
323 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
324 | 324 | |
325 | 325 | //load money helper |
326 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
326 | + EE_Registry::instance()->load_helper('Money'); |
|
327 | 327 | |
328 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
328 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
329 | 329 | |
330 | 330 | $update_prices = $create_new_TKT = FALSE; |
331 | 331 | |
332 | 332 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
333 | 333 | |
334 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
335 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
334 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
335 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
336 | 336 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
337 | 337 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
338 | 338 | |
339 | 339 | // trim inputs to ensure any excess whitespace is removed. |
340 | 340 | $tkt = array_map( |
341 | - function( $ticket_data ) { |
|
342 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
341 | + function($ticket_data) { |
|
342 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
343 | 343 | }, |
344 | 344 | $tkt |
345 | 345 | ); |
346 | 346 | |
347 | 347 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
348 | 348 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
349 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
349 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
350 | 350 | |
351 | 351 | //note incoming base price needs converted from localized value. |
352 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
352 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
353 | 353 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
354 | 354 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
355 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
355 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
356 | 356 | |
357 | 357 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
358 | 358 | |
359 | 359 | $now = null; |
360 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
360 | + if (empty($tkt['TKT_start_date'])) { |
|
361 | 361 | //lets' use now in the set timezone. |
362 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
363 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
362 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
363 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
366 | + if (empty($tkt['TKT_end_date'])) { |
|
367 | 367 | /** |
368 | 368 | * set the TKT_end_date to the first datetime attached to the ticket. |
369 | 369 | */ |
370 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
371 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
370 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
371 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $TKT_values = array( |
375 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
376 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
377 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
378 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
375 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
376 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
377 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
378 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
379 | 379 | 'TKT_start_date' => $tkt['TKT_start_date'], |
380 | 380 | 'TKT_end_date' => $tkt['TKT_end_date'], |
381 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
382 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
384 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
381 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
382 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
384 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
385 | 385 | 'TKT_row' => $row, |
386 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
387 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
388 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
386 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
387 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
388 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
389 | 389 | 'TKT_price' => $ticket_price |
390 | 390 | ); |
391 | 391 | |
392 | 392 | |
393 | 393 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
394 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
394 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
395 | 395 | $TKT_values['TKT_ID'] = 0; |
396 | 396 | $TKT_values['TKT_is_default'] = 0; |
397 | 397 | $update_prices = TRUE; |
@@ -403,21 +403,21 @@ discard block |
||
403 | 403 | // but DID have it's items modified. |
404 | 404 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
405 | 405 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
406 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
407 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
408 | - if ( $TKT instanceof EE_Ticket ) { |
|
406 | + if (absint($TKT_values['TKT_ID'])) { |
|
407 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
408 | + if ($TKT instanceof EE_Ticket) { |
|
409 | 409 | |
410 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
410 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
411 | 411 | // are there any registrations using this ticket ? |
412 | 412 | $tickets_sold = $TKT->count_related( |
413 | 413 | 'Registration', |
414 | - array( array( |
|
415 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
416 | - ) ) |
|
414 | + array(array( |
|
415 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
416 | + )) |
|
417 | 417 | ); |
418 | 418 | //set ticket formats |
419 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
420 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
419 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
420 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
421 | 421 | |
422 | 422 | // let's just check the total price for the existing ticket |
423 | 423 | // and determine if it matches the new total price. |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | ? TRUE : FALSE; |
428 | 428 | |
429 | 429 | //set new values |
430 | - foreach ( $TKT_values as $field => $value ) { |
|
431 | - if ( $field === 'TKT_qty' ) { |
|
432 | - $TKT->set_qty( $value ); |
|
430 | + foreach ($TKT_values as $field => $value) { |
|
431 | + if ($field === 'TKT_qty') { |
|
432 | + $TKT->set_qty($value); |
|
433 | 433 | } else { |
434 | - $TKT->set( $field, $value ); |
|
434 | + $TKT->set($field, $value); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
439 | - if ( $create_new_TKT ) { |
|
440 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
439 | + if ($create_new_TKT) { |
|
440 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $TKT = EE_Ticket::new_instance( |
447 | 447 | $TKT_values, |
448 | 448 | $timezone, |
449 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
449 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
450 | 450 | ); |
451 | - if ( $TKT instanceof EE_Ticket ) { |
|
451 | + if ($TKT instanceof EE_Ticket) { |
|
452 | 452 | // make sure ticket has an ID of setting relations won't work |
453 | 453 | $TKT->save(); |
454 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
454 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
455 | 455 | $update_prices = TRUE; |
456 | 456 | } |
457 | 457 | } |
@@ -459,38 +459,38 @@ discard block |
||
459 | 459 | //$TKT->save(); |
460 | 460 | |
461 | 461 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
462 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
463 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
462 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
463 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
464 | 464 | EE_Registry::instance()->load_helper('DTT_Helper'); |
465 | 465 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
466 | 466 | } |
467 | 467 | |
468 | 468 | //let's make sure the base price is handled |
469 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
469 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
470 | 470 | |
471 | 471 | //add/update price_modifiers |
472 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
472 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
473 | 473 | |
474 | 474 | //need to make sue that the TKT_price is accurate after saving the prices. |
475 | 475 | $TKT->ensure_TKT_Price_correct(); |
476 | 476 | |
477 | 477 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
478 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
479 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
478 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
479 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
480 | 480 | $update_prices = TRUE; |
481 | 481 | $new_default = clone $TKT; |
482 | - $new_default->set( 'TKT_ID', 0 ); |
|
483 | - $new_default->set( 'TKT_is_default', 1 ); |
|
484 | - $new_default->set( 'TKT_row', 1 ); |
|
485 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
482 | + $new_default->set('TKT_ID', 0); |
|
483 | + $new_default->set('TKT_is_default', 1); |
|
484 | + $new_default->set('TKT_row', 1); |
|
485 | + $new_default->set('TKT_price', $ticket_price); |
|
486 | 486 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
487 | 487 | $new_default->_remove_relations('Datetime'); |
488 | 488 | //todo we need to add the current attached prices as new prices to the new default ticket. |
489 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
489 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
490 | 490 | //don't forget the base price! |
491 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
491 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
492 | 492 | $new_default->save(); |
493 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
493 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | //let's assign any tickets that have been setup to the saved_tickets tracker |
502 | 502 | //save existing TKT |
503 | 503 | $TKT->save(); |
504 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
504 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
505 | 505 | //save new TKT |
506 | 506 | $new_tkt->save(); |
507 | 507 | //add new ticket to array |
508 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
508 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
509 | 509 | |
510 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
510 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
511 | 511 | |
512 | 512 | } else { |
513 | 513 | //add tkt to saved tkts |
514 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
514 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
515 | 515 | |
516 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
516 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | } |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
524 | 524 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
525 | 525 | // No sense in keeping all the related data in the db! |
526 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
526 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
528 | 528 | |
529 | - foreach ( $tickets_removed as $id ) { |
|
530 | - $id = absint( $id ); |
|
529 | + foreach ($tickets_removed as $id) { |
|
530 | + $id = absint($id); |
|
531 | 531 | |
532 | 532 | //get the ticket for this id |
533 | 533 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
534 | 534 | |
535 | 535 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
536 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
536 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
537 | 537 | continue; |
538 | 538 | |
539 | 539 | // if this tkt has any registrations attached so then we just ARCHIVE |
540 | 540 | // because we don't actually permanently delete these tickets. |
541 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
541 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
542 | 542 | $tkt_to_remove->delete(); |
543 | 543 | continue; |
544 | 544 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
548 | 548 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
549 | 549 | |
550 | - foreach( $dtts as $dtt ) { |
|
550 | + foreach ($dtts as $dtt) { |
|
551 | 551 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
552 | 552 | } |
553 | 553 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
556 | 556 | $tkt_to_remove->delete_related_permanently('Price'); |
557 | 557 | |
558 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
558 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
559 | 559 | |
560 | 560 | // finally let's delete this ticket |
561 | 561 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -587,39 +587,39 @@ discard block |
||
587 | 587 | // and removing the ticket from datetimes it got removed from. |
588 | 588 | |
589 | 589 | // first let's add datetimes |
590 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
591 | - foreach ( $added_datetimes as $row_id ) { |
|
592 | - $row_id = (int)$row_id; |
|
593 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
594 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
590 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
591 | + foreach ($added_datetimes as $row_id) { |
|
592 | + $row_id = (int) $row_id; |
|
593 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
594 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
595 | 595 | // Is this an existing ticket (has an ID) and does it have any sold? |
596 | 596 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
597 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
598 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
599 | - $saved_datetimes[ $row_id ]->save(); |
|
597 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
598 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
599 | + $saved_datetimes[$row_id]->save(); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
604 | 604 | // then remove datetimes |
605 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
606 | - foreach ( $removed_datetimes as $row_id ) { |
|
607 | - $row_id = (int)$row_id; |
|
605 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
606 | + foreach ($removed_datetimes as $row_id) { |
|
607 | + $row_id = (int) $row_id; |
|
608 | 608 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
609 | 609 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
610 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
611 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
610 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
611 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
612 | 612 | // Is this an existing ticket (has an ID) and does it have any sold? |
613 | 613 | // If so, then we need to remove it's sold from the DTT_sold. |
614 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
615 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
616 | - $saved_datetimes[ $row_id ]->save(); |
|
614 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
615 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
616 | + $saved_datetimes[$row_id]->save(); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | 621 | // cap ticket qty by datetime reg limits |
622 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
622 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
623 | 623 | return $ticket; |
624 | 624 | } |
625 | 625 | |
@@ -640,39 +640,39 @@ discard block |
||
640 | 640 | EE_Ticket $ticket, |
641 | 641 | $price_rows = array(), |
642 | 642 | $ticket_price = 0, |
643 | - $base_price = 0 , |
|
643 | + $base_price = 0, |
|
644 | 644 | $base_price_id = 0 |
645 | 645 | ) { |
646 | 646 | |
647 | 647 | // create new ticket that's a copy of the existing |
648 | 648 | // except a new id of course (and not archived) |
649 | 649 | // AND has the new TKT_price associated with it. |
650 | - $new_ticket = clone( $ticket ); |
|
651 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
652 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
653 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
654 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
650 | + $new_ticket = clone($ticket); |
|
651 | + $new_ticket->set('TKT_ID', 0); |
|
652 | + $new_ticket->set('TKT_deleted', 0); |
|
653 | + $new_ticket->set('TKT_price', $ticket_price); |
|
654 | + $new_ticket->set('TKT_sold', 0); |
|
655 | 655 | // let's get a new ID for this ticket |
656 | 656 | $new_ticket->save(); |
657 | 657 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
658 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
658 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
659 | 659 | $new_ticket = $this->_update_ticket_datetimes( |
660 | 660 | $new_ticket, |
661 | 661 | $datetimes_on_existing, |
662 | - array_keys( $datetimes_on_existing ) |
|
662 | + array_keys($datetimes_on_existing) |
|
663 | 663 | ); |
664 | 664 | |
665 | 665 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
666 | 666 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
667 | 667 | // available. |
668 | - if ( $ticket->sold() > 0 ) { |
|
668 | + if ($ticket->sold() > 0) { |
|
669 | 669 | $new_qty = $ticket->qty() - $ticket->sold(); |
670 | - $new_ticket->set_qty( $new_qty ); |
|
670 | + $new_ticket->set_qty($new_qty); |
|
671 | 671 | } |
672 | 672 | //now we update the prices just for this ticket |
673 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
673 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
674 | 674 | //and we update the base price |
675 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
675 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
676 | 676 | return $new_ticket; |
677 | 677 | } |
678 | 678 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
693 | 693 | * @return EE_Ticket |
694 | 694 | */ |
695 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
695 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
696 | 696 | |
697 | 697 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
698 | 698 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $updated_prices = array(); |
701 | 701 | |
702 | 702 | // if $base_price ! FALSE then updating a base price. |
703 | - if ( $base_price !== FALSE ) { |
|
703 | + if ($base_price !== FALSE) { |
|
704 | 704 | $prices[1] = array( |
705 | 705 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
706 | 706 | 'PRT_ID' => 1, |
@@ -711,47 +711,47 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | //possibly need to save tkt |
714 | - if ( ! $ticket->ID() ) |
|
714 | + if ( ! $ticket->ID()) |
|
715 | 715 | $ticket->save(); |
716 | 716 | |
717 | - foreach ( $prices as $row => $prc ) { |
|
718 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
719 | - if ( empty($prt_id) ) |
|
717 | + foreach ($prices as $row => $prc) { |
|
718 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
719 | + if (empty($prt_id)) |
|
720 | 720 | continue; //prices MUST have a price type id. |
721 | 721 | $PRC_values = array( |
722 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
722 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
723 | 723 | 'PRT_ID' => $prt_id, |
724 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
725 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
726 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
724 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
725 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
726 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
727 | 727 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
728 | 728 | 'PRC_order' => $row |
729 | 729 | ); |
730 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
730 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
731 | 731 | $PRC_values['PRC_ID'] = 0; |
732 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
732 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
733 | 733 | } else { |
734 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
734 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
735 | 735 | //update this price with new values |
736 | - foreach ( $PRC_values as $field => $newprc ) { |
|
737 | - $PRC->set( $field, $newprc ); |
|
736 | + foreach ($PRC_values as $field => $newprc) { |
|
737 | + $PRC->set($field, $newprc); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | $PRC->save(); |
741 | 741 | $prcid = $PRC->ID(); |
742 | 742 | $updated_prices[$prcid] = $PRC; |
743 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
743 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | //now let's remove any prices that got removed from the ticket |
747 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
747 | + if ( ! empty ($current_prices_on_ticket)) { |
|
748 | 748 | $current = array_keys($current_prices_on_ticket); |
749 | 749 | $updated = array_keys($updated_prices); |
750 | 750 | $prices_to_remove = array_diff($current, $updated); |
751 | - if ( !empty( $prices_to_remove ) ) { |
|
752 | - foreach ( $prices_to_remove as $prc_id ) { |
|
751 | + if ( ! empty($prices_to_remove)) { |
|
752 | + foreach ($prices_to_remove as $prc_id) { |
|
753 | 753 | $p = $current_prices_on_ticket[$prc_id]; |
754 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
754 | + $ticket->_remove_relation_to($p, 'Price'); |
|
755 | 755 | |
756 | 756 | //delete permanently the price |
757 | 757 | $p->delete_permanently(); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | |
767 | - public function autosave_handling( $event_admin_obj ) { |
|
767 | + public function autosave_handling($event_admin_obj) { |
|
768 | 768 | return $event_admin_obj; //doing nothing for the moment. |
769 | 769 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
770 | 770 | |
@@ -798,12 +798,12 @@ discard block |
||
798 | 798 | |
799 | 799 | //default main template args |
800 | 800 | $main_template_args = array( |
801 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
801 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
802 | 802 | 'existing_datetime_ids' => '', |
803 | 803 | 'total_dtt_rows' => 1, |
804 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
804 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
805 | 805 | 'datetime_rows' => '', |
806 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
806 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
807 | 807 | 'ticket_rows' => '', |
808 | 808 | 'existing_ticket_ids' => '', |
809 | 809 | 'total_ticket_rows' => 1, |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
815 | 815 | |
816 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
816 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * 1. Start with retrieving Datetimes |
@@ -821,37 +821,37 @@ discard block |
||
821 | 821 | * 3. For each ticket get related prices |
822 | 822 | */ |
823 | 823 | |
824 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
825 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
824 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
825 | + $times = $DTM->get_all_event_dates($evtID); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | |
829 | 829 | $main_template_args['total_dtt_rows'] = count($times); |
830 | - foreach ( $times as $time ) { |
|
830 | + foreach ($times as $time) { |
|
831 | 831 | $dttid = $time->get('DTT_ID'); |
832 | 832 | $dttrow = $time->get('DTT_order'); |
833 | 833 | $existing_datetime_ids[] = $dttid; |
834 | 834 | |
835 | 835 | //tickets attached |
836 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
836 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
837 | 837 | |
838 | 838 | //if there are no related tickets this is likely a new event OR autodraft |
839 | 839 | // event so we need to generate the default tickets because dtts |
840 | 840 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
841 | 841 | // datetime on the event. |
842 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
842 | + if (empty ($related_tickets) && count($times) < 2) { |
|
843 | 843 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
844 | 844 | |
845 | 845 | //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
846 | 846 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
847 | 847 | |
848 | - $main_default_ticket = reset( $related_tickets ); |
|
849 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
850 | - foreach ( $default_prices as $default_price ) { |
|
851 | - if ( $default_price->is_base_price() ) { |
|
848 | + $main_default_ticket = reset($related_tickets); |
|
849 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
850 | + foreach ($default_prices as $default_price) { |
|
851 | + if ($default_price->is_base_price()) { |
|
852 | 852 | continue; |
853 | 853 | } |
854 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
854 | + $main_default_ticket->cache('Price', $default_price); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -860,11 +860,11 @@ discard block |
||
860 | 860 | //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information. |
861 | 861 | |
862 | 862 | //loop through and setup the ticket rows and make sure the order is set. |
863 | - foreach ( $related_tickets as $ticket ) { |
|
863 | + foreach ($related_tickets as $ticket) { |
|
864 | 864 | $tktid = $ticket->get('TKT_ID'); |
865 | 865 | $tktrow = $ticket->get('TKT_row'); |
866 | 866 | //we only want unique tickets in our final display!! |
867 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
867 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
868 | 868 | $existing_ticket_ids[] = $tktid; |
869 | 869 | $all_tickets[] = $ticket; |
870 | 870 | } |
@@ -873,56 +873,56 @@ discard block |
||
873 | 873 | $datetime_tickets[$dttid][] = $tktrow; |
874 | 874 | |
875 | 875 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
876 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
876 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
877 | 877 | $ticket_datetimes[$tktid][] = $dttrow; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
881 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
882 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
883 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
881 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
882 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
883 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
884 | 884 | |
885 | 885 | //sort $all_tickets by order |
886 | - usort( $all_tickets, function( $a, $b ) { |
|
886 | + usort($all_tickets, function($a, $b) { |
|
887 | 887 | $a_order = (int) $a->get('TKT_order'); |
888 | 888 | $b_order = (int) $b->get('TKT_order'); |
889 | - if ( $a_order == $b_order ) { |
|
889 | + if ($a_order == $b_order) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
892 | + return ($a_order < $b_order) ? -1 : 1; |
|
893 | 893 | }); |
894 | 894 | |
895 | 895 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
896 | 896 | $dttrow = 1; |
897 | - foreach ( $times as $time ) { |
|
898 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
897 | + foreach ($times as $time) { |
|
898 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
899 | 899 | $dttrow++; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //then loop through all tickets for the ticket rows. |
903 | 903 | $tktrow = 1; |
904 | - foreach ( $all_tickets as $ticket ) { |
|
905 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
904 | + foreach ($all_tickets as $ticket) { |
|
905 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
906 | 906 | $tktrow++; |
907 | 907 | } |
908 | 908 | |
909 | 909 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
910 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
911 | - EEH_Template::display_template( $template, $main_template_args ); |
|
910 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
911 | + EEH_Template::display_template($template, $main_template_args); |
|
912 | 912 | return; |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
917 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
918 | 918 | |
919 | 919 | $dtt_display_template_args = array( |
920 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
921 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
920 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
921 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
922 | 922 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
923 | 923 | ); |
924 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
924 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string Generated edit row. |
942 | 942 | */ |
943 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
943 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
944 | 944 | |
945 | 945 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
946 | 946 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -948,30 +948,30 @@ discard block |
||
948 | 948 | $template_args = array( |
949 | 949 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
950 | 950 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
951 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
951 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
952 | 952 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
953 | 953 | 'DTT_name' => $default ? '' : $dtt->name(), |
954 | 954 | 'DTT_description' => $default ? '' : $dtt->description(), |
955 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
956 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
957 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
955 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
956 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
957 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
958 | 958 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
959 | 959 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
960 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
960 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
962 | 962 | ); |
963 | 963 | |
964 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
964 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
965 | 965 | |
966 | 966 | //allow filtering of template args at this point. |
967 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
967 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
968 | 968 | |
969 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
970 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
969 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
970 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
974 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
974 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
975 | 975 | |
976 | 976 | $template_args = array( |
977 | 977 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -979,47 +979,47 @@ discard block |
||
979 | 979 | 'DTT_description' => $default ? '' : $dtt->description(), |
980 | 980 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
981 | 981 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
982 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
982 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
983 | 983 | 'DTT_ID' => $default ? '' : $dtt->ID() |
984 | 984 | ); |
985 | 985 | |
986 | 986 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
987 | - if ( !$default ) { |
|
987 | + if ( ! $default) { |
|
988 | 988 | $tktrow = 1; |
989 | - foreach ( $all_tickets as $ticket ) { |
|
990 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
989 | + foreach ($all_tickets as $ticket) { |
|
990 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
991 | 991 | $tktrow++; |
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | 995 | //filter template args at this point |
996 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
996 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
997 | 997 | |
998 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
998 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | |
1004 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1005 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1006 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1004 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1005 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1006 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1007 | 1007 | |
1008 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1008 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1009 | 1009 | $template_args = array( |
1010 | 1010 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1011 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1011 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1012 | 1012 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1013 | 1013 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1014 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1014 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1016 | 1016 | ); |
1017 | 1017 | |
1018 | 1018 | //filter template args |
1019 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1019 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1020 | 1020 | |
1021 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1021 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | |
@@ -1041,37 +1041,37 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return [type] [description] |
1043 | 1043 | */ |
1044 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1044 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1045 | 1045 | |
1046 | 1046 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1047 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1047 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1048 | 1048 | |
1049 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1049 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1050 | 1050 | |
1051 | 1051 | //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on |
1052 | 1052 | //the object. This is done by not including any query_params. |
1053 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1054 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1053 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1054 | + $prices = $ticket->get_many_related('Price'); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1058 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1058 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1059 | 1059 | |
1060 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1060 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1061 | 1061 | |
1062 | 1062 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1063 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1063 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1064 | 1064 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1065 | 1065 | |
1066 | 1066 | //breaking out complicated condition for ticket_status |
1067 | - if ( $default ) { |
|
1068 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1067 | + if ($default) { |
|
1068 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1069 | 1069 | } else { |
1070 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1070 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //breaking out complicated condition for TKT_taxable |
1074 | - if ( $default ) { |
|
1074 | + if ($default) { |
|
1075 | 1075 | $TKT_taxable = ''; |
1076 | 1076 | } else { |
1077 | 1077 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1086,19 +1086,19 @@ discard block |
||
1086 | 1086 | 'edit_tkt_expanded' => '', |
1087 | 1087 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1088 | 1088 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1089 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1090 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1091 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1089 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1090 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1091 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1092 | 1092 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1093 | 1093 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1094 | 1094 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1095 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1096 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1097 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1098 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1099 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1095 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1096 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1097 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1098 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1099 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1100 | 1100 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1101 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1101 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1102 | 1102 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1103 | 1103 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1104 | 1104 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1107,99 +1107,99 @@ discard block |
||
1107 | 1107 | 'ticket_price_rows' => '', |
1108 | 1108 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1109 | 1109 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1110 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1111 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1110 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1111 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1112 | 1112 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1113 | 1113 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1114 | 1114 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1115 | 1115 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1116 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1116 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1117 | 1117 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1118 | 1118 | 'TKT_taxable' => $TKT_taxable, |
1119 | 1119 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1120 | 1120 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1121 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1121 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1122 | 1122 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1123 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1124 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1123 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1124 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1125 | 1125 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1126 | 1126 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1127 | 1127 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1130 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1131 | 1131 | |
1132 | 1132 | //handle rows that should NOT be empty |
1133 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1133 | + if (empty($template_args['TKT_start_date'])) { |
|
1134 | 1134 | //if empty then the start date will be now. |
1135 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1136 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1135 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1136 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1139 | + if (empty($template_args['TKT_end_date'])) { |
|
1140 | 1140 | |
1141 | 1141 | //get the earliest datetime (if present); |
1142 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1142 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1143 | 1143 | |
1144 | - if ( !empty( $earliest_dtt ) ) { |
|
1145 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1144 | + if ( ! empty($earliest_dtt)) { |
|
1145 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1146 | 1146 | } else { |
1147 | 1147 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1148 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1148 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1149 | 1149 | } |
1150 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1150 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | //generate ticket_datetime items |
1154 | - if ( ! $default ) { |
|
1154 | + if ( ! $default) { |
|
1155 | 1155 | $dttrow = 1; |
1156 | - foreach ( $all_dtts as $dtt ) { |
|
1157 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1156 | + foreach ($all_dtts as $dtt) { |
|
1157 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1158 | 1158 | $dttrow++; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | $prcrow = 1; |
1163 | - foreach ( $prices as $price ) { |
|
1164 | - if ( $price->is_base_price() ) { |
|
1163 | + foreach ($prices as $price) { |
|
1164 | + if ($price->is_base_price()) { |
|
1165 | 1165 | $prcrow++; |
1166 | 1166 | continue; |
1167 | 1167 | } |
1168 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1169 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1170 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1168 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1169 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1170 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1171 | 1171 | $prcrow++; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | //filter $template_args |
1175 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1175 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1176 | 1176 | |
1177 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1177 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1185 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1186 | 1186 | $tax_rows = ''; |
1187 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1187 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1188 | 1188 | $template_args = array(); |
1189 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | - foreach ( $taxes as $tax ) { |
|
1191 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1189 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | + foreach ($taxes as $tax) { |
|
1191 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1192 | 1192 | $template_args = array( |
1193 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1193 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1194 | 1194 | 'tax_id' => $tax->ID(), |
1195 | 1195 | 'tkt_row' => $tktrow, |
1196 | 1196 | 'tax_label' => $tax->get('PRC_name'), |
1197 | 1197 | 'tax_added' => $tax_added, |
1198 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1198 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1199 | 1199 | 'tax_amount' => $tax->get('PRC_amount') |
1200 | 1200 | ); |
1201 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1202 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1201 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1202 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1207,81 +1207,81 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1211 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1210 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1211 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1212 | 1212 | return $subtotal * $tax->get('PRC_amount') / 100; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | |
1217 | 1217 | |
1218 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1219 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1218 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1219 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1220 | 1220 | $template_args = array( |
1221 | 1221 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1222 | 1222 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1223 | 1223 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1224 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1224 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1225 | 1225 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1226 | 1226 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1227 | 1227 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1228 | 1228 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1229 | 1229 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1230 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1233 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1230 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1233 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1235 | 1235 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1236 | 1236 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1237 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1238 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1237 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1238 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1239 | 1239 | ); |
1240 | 1240 | |
1241 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1241 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1242 | 1242 | |
1243 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1243 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | |
1248 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1249 | - if ( $price->is_base_price() ) { |
|
1250 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1248 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1249 | + if ($price->is_base_price()) { |
|
1250 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1251 | 1251 | } else { |
1252 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1252 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1258 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1259 | 1259 | $template_args = array( |
1260 | 1260 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1261 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1262 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1261 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1262 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1263 | 1263 | 'PRT_name' => __('Price', 'event_espresso'), |
1264 | 1264 | 'price_selected_operator' => '+', |
1265 | 1265 | 'price_selected_is_percent' => 0 |
1266 | 1266 | ); |
1267 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1267 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1268 | 1268 | |
1269 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1269 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1270 | 1270 | |
1271 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1271 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | |
1276 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1277 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1278 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1279 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1281 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1276 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1277 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1278 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1279 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1281 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1282 | 1282 | $price_option_spans = ''; |
1283 | 1283 | //setup pricetypes for selector |
1284 | - foreach ( $price_types as $price_type ) { |
|
1284 | + foreach ($price_types as $price_type) { |
|
1285 | 1285 | $all_price_types[] = array( |
1286 | 1286 | 'id' => $price_type->ID(), |
1287 | 1287 | 'text' => $price_type->get('PRT_name'), |
@@ -1293,50 +1293,50 @@ discard block |
||
1293 | 1293 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1294 | 1294 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1295 | 1295 | ); |
1296 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1296 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1299 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1300 | 1300 | $main_name = $select_name; |
1301 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1301 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1302 | 1302 | |
1303 | 1303 | $template_args = array( |
1304 | 1304 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1305 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1306 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1305 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1306 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1307 | 1307 | 'main_name' => $main_name, |
1308 | 1308 | 'selected_price_type_id' => $selected_price_type_id, |
1309 | 1309 | 'price_option_spans' => $price_option_spans, |
1310 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1311 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1310 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1311 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1312 | 1312 | 'disabled' => $disabled |
1313 | 1313 | ); |
1314 | 1314 | |
1315 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1315 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1316 | 1316 | |
1317 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1317 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1318 | 1318 | |
1319 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1319 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | |
1323 | 1323 | |
1324 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1325 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1326 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1324 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1325 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1326 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1328 | 1328 | $template_args = array( |
1329 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1329 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1330 | 1330 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1331 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1332 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1333 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1331 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1332 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1333 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1334 | 1334 | 'tkt_status_class' => '', |
1335 | 1335 | ); |
1336 | 1336 | |
1337 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1338 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1337 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1338 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1344,53 +1344,53 @@ discard block |
||
1344 | 1344 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1345 | 1345 | $template_args = array( |
1346 | 1346 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1347 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1347 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1349 | 1349 | 'default_price_rows' => '', |
1350 | 1350 | 'default_base_price_amount' => 0, |
1351 | 1351 | 'default_base_price_name' => '', |
1352 | 1352 | 'default_base_price_description' => '', |
1353 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1354 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1353 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1354 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1355 | 1355 | 'existing_available_datetime_tickets_list' => '', |
1356 | 1356 | 'existing_available_ticket_datetimes_list' => '', |
1357 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1358 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1357 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1358 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | 1361 | $tktrow = 1; |
1362 | - foreach ( $all_tickets as $ticket ) { |
|
1363 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1362 | + foreach ($all_tickets as $ticket) { |
|
1363 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1364 | 1364 | $tktrow++; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | 1368 | $dttrow = 1; |
1369 | - foreach ( $all_dtts as $dtt ) { |
|
1370 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1369 | + foreach ($all_dtts as $dtt) { |
|
1370 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1371 | 1371 | $dttrow++; |
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1375 | 1375 | $prcrow = 1; |
1376 | - foreach ( $default_prices as $price ) { |
|
1377 | - if ( $price->is_base_price() ) { |
|
1376 | + foreach ($default_prices as $price) { |
|
1377 | + if ($price->is_base_price()) { |
|
1378 | 1378 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1379 | 1379 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1380 | 1380 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1381 | 1381 | $prcrow++; |
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1385 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1386 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1384 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1385 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1386 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1387 | 1387 | $prcrow++; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1390 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1391 | 1391 | |
1392 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1392 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 |