@@ -11,18 +11,18 @@ discard block |
||
11 | 11 | |
12 | 12 | $row = 1; |
13 | 13 | $max = 1; |
14 | -$ticket_count = count( $tickets ); |
|
14 | +$ticket_count = count($tickets); |
|
15 | 15 | $ticket_status_display = ''; |
16 | -if ( ! $ticket_count ) { |
|
16 | +if ( ! $ticket_count) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | 20 | $required_ticket_sold_out = FALSE; |
21 | -$template_settings = isset ( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) |
|
21 | +$template_settings = isset (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
22 | 22 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
23 | 23 | : new EE_Ticket_Selector_Config(); |
24 | 24 | |
25 | -$tax_settings = isset ( EE_Registry::instance()->CFG->tax_settings ) |
|
25 | +$tax_settings = isset (EE_Registry::instance()->CFG->tax_settings) |
|
26 | 26 | ? EE_Registry::instance()->CFG->tax_settings |
27 | 27 | : new EE_Tax_Config(); |
28 | 28 | |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | |
32 | 32 | ob_start(); |
33 | 33 | |
34 | -foreach ( $tickets as $TKT_ID => $ticket ) { |
|
35 | - if ( $ticket instanceof EE_Ticket ) { |
|
34 | +foreach ($tickets as $TKT_ID => $ticket) { |
|
35 | + if ($ticket instanceof EE_Ticket) { |
|
36 | 36 | $cols = 2; |
37 | 37 | $max = $ticket->max(); |
38 | 38 | $min = 0; |
39 | 39 | $remaining = $ticket->remaining(); |
40 | - if ( $ticket->is_on_sale() && $ticket->is_remaining() ) { |
|
40 | + if ($ticket->is_on_sale() && $ticket->is_remaining()) { |
|
41 | 41 | // offer the number of $tickets_remaining or $max_atndz, whichever is smaller |
42 | - $max = min( $remaining, $max_atndz ); |
|
42 | + $max = min($remaining, $max_atndz); |
|
43 | 43 | // but... we also want to restrict the number of tickets by the ticket max setting, |
44 | 44 | // however, the max still can't be higher than what was just set above |
45 | - $max = $ticket->max() > 0 ? min( $ticket->max(), $max ) : $max; |
|
45 | + $max = $ticket->max() > 0 ? min($ticket->max(), $max) : $max; |
|
46 | 46 | // and we also want to restrict the minimum number of tickets by the ticket min setting |
47 | 47 | $min = $ticket->min() > 0 ? $ticket->min() : 0; |
48 | 48 | // and if the ticket is required, then make sure that min qty is at least 1 |
49 | - $min = $ticket->required() ? max( $min, 1 ) : $min; |
|
49 | + $min = $ticket->required() ? max($min, 1) : $min; |
|
50 | 50 | } else { |
51 | 51 | // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
52 | 52 | $required_ticket_sold_out = $ticket->required() && ! $remaining ? $ticket->start_date() : $required_ticket_sold_out; |
@@ -58,41 +58,41 @@ discard block |
||
58 | 58 | $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
59 | 59 | $ticket_bundle = FALSE; |
60 | 60 | // for ticket bundles, set min and max qty the same |
61 | - if ( $ticket->min() !== 0 && $ticket->min() === $ticket->max() ) { |
|
61 | + if ($ticket->min() !== 0 && $ticket->min() === $ticket->max()) { |
|
62 | 62 | $ticket_price *= $ticket->min(); |
63 | 63 | $ticket_bundle = TRUE; |
64 | 64 | } |
65 | - $ticket_price = apply_filters( 'FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket ); |
|
65 | + $ticket_price = apply_filters('FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket); |
|
66 | 66 | // if a previous required ticket with the same sale start date is sold out, then mark this ticket as sold out as well. |
67 | 67 | // tickets that go on sale at a later date than the required ticket will NOT be affected |
68 | 68 | $tkt_status = $required_ticket_sold_out !== FALSE && $required_ticket_sold_out === $ticket->start_date() ? EE_Ticket::sold_out : $ticket->ticket_status(); |
69 | 69 | $tkt_status = $event_status === EE_Datetime::sold_out ? EE_Ticket::sold_out : $tkt_status; |
70 | 70 | // check ticket status |
71 | - switch ( $tkt_status ) { |
|
71 | + switch ($tkt_status) { |
|
72 | 72 | // sold_out |
73 | 73 | case EE_Ticket::sold_out : |
74 | - $ticket_status = '<span class="ticket-sales-sold-out">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
74 | + $ticket_status = '<span class="ticket-sales-sold-out">'.$ticket->ticket_status(TRUE).'</span>'; |
|
75 | 75 | $status_class = 'ticket-sales-sold-out lt-grey-text'; |
76 | 76 | break; |
77 | 77 | // expired |
78 | 78 | case EE_Ticket::expired : |
79 | - $ticket_status = '<span class="ticket-sales-expired">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
79 | + $ticket_status = '<span class="ticket-sales-expired">'.$ticket->ticket_status(TRUE).'</span>'; |
|
80 | 80 | $status_class = 'ticket-sales-expired lt-grey-text'; |
81 | 81 | break; |
82 | 82 | // archived |
83 | 83 | case EE_Ticket::archived : |
84 | - $ticket_status = '<span class="archived-ticket">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
84 | + $ticket_status = '<span class="archived-ticket">'.$ticket->ticket_status(TRUE).'</span>'; |
|
85 | 85 | $status_class = 'archived-ticket hidden'; |
86 | 86 | break; |
87 | 87 | // pending |
88 | 88 | case EE_Ticket::pending : |
89 | - $ticket_status = '<span class="ticket-pending">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
89 | + $ticket_status = '<span class="ticket-pending">'.$ticket->ticket_status(TRUE).'</span>'; |
|
90 | 90 | $status_class = 'ticket-pending'; |
91 | 91 | break; |
92 | 92 | // onsale |
93 | 93 | case EE_Ticket::onsale : |
94 | 94 | default : |
95 | - $ticket_status = '<span class="ticket-on-sale">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
95 | + $ticket_status = '<span class="ticket-on-sale">'.$ticket->ticket_status(TRUE).'</span>'; |
|
96 | 96 | $status_class = 'ticket-on-sale'; |
97 | 97 | break; |
98 | 98 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | "tckt-slctr-tkt-details-{$EVT_ID}-{$TKT_ID}" |
133 | 133 | ); |
134 | 134 | ?> |
135 | - <tr class="tckt-slctr-tbl-tr <?php echo $status_class . ' ' . espresso_get_object_css_class( $ticket ); ?>"> |
|
135 | + <tr class="tckt-slctr-tbl-tr <?php echo $status_class.' '.espresso_get_object_css_class($ticket); ?>"> |
|
136 | 136 | <?php |
137 | 137 | /** |
138 | 138 | * Allow plugins to hook in and abort the generation and display of the contents of this |
@@ -144,24 +144,24 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @var string|bool |
146 | 146 | */ |
147 | - if ( false !== ( $new_row_cells_content = apply_filters( 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class ) ) ) { |
|
147 | + if (false !== ($new_row_cells_content = apply_filters('FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class))) { |
|
148 | 148 | echo $new_row_cells_content; |
149 | 149 | echo '</tr>'; |
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | ?> |
153 | 153 | <td class="tckt-slctr-tbl-td-name"> |
154 | - <b><?php echo $ticket->get_pretty('TKT_name');?></b> |
|
155 | - <?php if ( $template_settings->show_ticket_details ) : ?> |
|
156 | - <a id="display-<?php echo $ticket_details_css_id; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __( 'click to show additional ticket details', 'event_espresso' )) ); ?>"> |
|
157 | - <?php echo sprintf( __( 'show%1$sdetails%1$s+', 'event_espresso' ), ' ' ); ?> |
|
154 | + <b><?php echo $ticket->get_pretty('TKT_name'); ?></b> |
|
155 | + <?php if ($template_settings->show_ticket_details) : ?> |
|
156 | + <a id="display-<?php echo $ticket_details_css_id; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __('click to show additional ticket details', 'event_espresso'))); ?>"> |
|
157 | + <?php echo sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '); ?> |
|
158 | 158 | </a> |
159 | - <a id="hide-<?php echo $ticket_details_css_id; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __( 'click to hide additional ticket details', 'event_espresso' )) ); ?>" style="display:none;"> |
|
160 | - <?php echo sprintf( __( 'hide%1$sdetails%1$s-', 'event_espresso' ), ' ' ); ?> |
|
159 | + <a id="hide-<?php echo $ticket_details_css_id; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __('click to hide additional ticket details', 'event_espresso'))); ?>" style="display:none;"> |
|
160 | + <?php echo sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '); ?> |
|
161 | 161 | </a> |
162 | 162 | <?php endif; //end show details check ?> |
163 | - <?php if ( $ticket->required() ) { ?> |
|
164 | - <p class="ticket-required-pg"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_required_message', __( 'This ticket is required and must be purchased.', 'event_espresso' )); ?></p> |
|
163 | + <?php if ($ticket->required()) { ?> |
|
164 | + <p class="ticket-required-pg"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_required_message', __('This ticket is required and must be purchased.', 'event_espresso')); ?></p> |
|
165 | 165 | <?php } ?> |
166 | 166 | <?php |
167 | 167 | // echo '<br/><b>$max_atndz : ' . $max_atndz . '</b>'; |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | </td> |
178 | 178 | <?php |
179 | 179 | if ( |
180 | - apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) |
|
180 | + apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE) |
|
181 | 181 | ) { ?> |
182 | 182 | <td class="tckt-slctr-tbl-td-price jst-rght"><?php |
183 | - echo EEH_Template::format_currency( $ticket_price ); |
|
183 | + echo EEH_Template::format_currency($ticket_price); |
|
184 | 184 | echo $ticket->taxable() ? '<span class="taxable-tickets-asterisk grey-text">*</span>' : ''; |
185 | 185 | ?> <span class="smaller-text no-bold"><?php |
186 | - if ( $ticket_bundle ) { |
|
187 | - echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __( ' / bundle', 'event_espresso' )); |
|
186 | + if ($ticket_bundle) { |
|
187 | + echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __(' / bundle', 'event_espresso')); |
|
188 | 188 | } else { |
189 | - echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_text', __( '', 'event_espresso' )); |
|
189 | + echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_text', __('', 'event_espresso')); |
|
190 | 190 | }?></span> </td> |
191 | 191 | <?php $cols++; ?> |
192 | 192 | <?php } ?> |
@@ -194,28 +194,28 @@ discard block |
||
194 | 194 | <?php |
195 | 195 | $hidden_input_qty = $max_atndz > 1 ? TRUE : FALSE; |
196 | 196 | $ticket_status_display = ''; |
197 | - if ( $max_atndz === 0 ) { |
|
197 | + if ($max_atndz === 0) { |
|
198 | 198 | // registration is CLOSED because admin set max attendees to ZERO |
199 | - $ticket_status_display = '<span class="sold-out">' . apply_filters( |
|
199 | + $ticket_status_display = '<span class="sold-out">'.apply_filters( |
|
200 | 200 | 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
201 | - __( 'Closed', 'event_espresso' ) |
|
202 | - ) . '</span>'; |
|
203 | - } else if ( $tkt_status === EE_Ticket::sold_out || $remaining === 0 ) { |
|
201 | + __('Closed', 'event_espresso') |
|
202 | + ).'</span>'; |
|
203 | + } else if ($tkt_status === EE_Ticket::sold_out || $remaining === 0) { |
|
204 | 204 | // SOLD OUT - no tickets remaining |
205 | - $ticket_status_display = '<span class="sold-out">' . apply_filters( |
|
205 | + $ticket_status_display = '<span class="sold-out">'.apply_filters( |
|
206 | 206 | 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
207 | - __( 'Sold Out', 'event_espresso' ) |
|
208 | - ) . '</span>'; |
|
209 | - } else if ( $tkt_status === EE_Ticket::expired || $tkt_status === EE_Ticket::archived ) { |
|
207 | + __('Sold Out', 'event_espresso') |
|
208 | + ).'</span>'; |
|
209 | + } else if ($tkt_status === EE_Ticket::expired || $tkt_status === EE_Ticket::archived) { |
|
210 | 210 | // expired or archived ticket |
211 | 211 | $ticket_status_display = $ticket_status; |
212 | - } else if ( $tkt_status === EE_Ticket::pending ) { |
|
212 | + } else if ($tkt_status === EE_Ticket::pending) { |
|
213 | 213 | // ticket not on sale yet |
214 | 214 | $ticket_status_display = '<span class="ticket-pending-pg"> |
215 | 215 | <span class="ticket-pending">' |
216 | 216 | . apply_filters( |
217 | 217 | 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
218 | - __( 'Goes On Sale', 'event_espresso' ) |
|
218 | + __('Goes On Sale', 'event_espresso') |
|
219 | 219 | ) |
220 | 220 | . '</span><br/> |
221 | 221 | <span class="small-text">' |
@@ -228,36 +228,36 @@ discard block |
||
228 | 228 | ) |
229 | 229 | . '</span> |
230 | 230 | </span>'; |
231 | - } else if ( $ticket->min() > $remaining ) { |
|
231 | + } else if ($ticket->min() > $remaining) { |
|
232 | 232 | // min qty purchasable is less than tickets available |
233 | 233 | $ticket_status_display = ' |
234 | 234 | <div class="archived-ticket-pg"> |
235 | 235 | <span class="archived-ticket small-text">' |
236 | - . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', __( 'Not Available', 'event_espresso' )) |
|
236 | + . apply_filters('FHEE__ticket_selector_chart_template__ticket_not_available_msg', __('Not Available', 'event_espresso')) |
|
237 | 237 | . '</span><br/> |
238 | 238 | </div>'; |
239 | - } else if ( $max_atndz === 1 ) { |
|
239 | + } else if ($max_atndz === 1) { |
|
240 | 240 | // only ONE attendee is allowed to register at a time |
241 | 241 | // display submit button since we have tickets available |
242 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
242 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
243 | 243 | ?> |
244 | - <input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row . '-'; ?>1" <?php echo $row === 1 ? ' checked="checked"' : ''; ?> title=""/> |
|
244 | + <input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row.'-'; ?>1" <?php echo $row === 1 ? ' checked="checked"' : ''; ?> title=""/> |
|
245 | 245 | <?php |
246 | 246 | $hidden_input_qty = FALSE; |
247 | 247 | |
248 | - } else if ( $max > 0 ) { |
|
248 | + } else if ($max > 0) { |
|
249 | 249 | // display submit button since we have tickets available |
250 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
250 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
251 | 251 | ?> |
252 | - <select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" title=""> |
|
252 | + <select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" title=""> |
|
253 | 253 | <?php |
254 | 254 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
255 | - if ( ! $ticket->required() && $min !== 0 ) { |
|
255 | + if ( ! $ticket->required() && $min !== 0) { |
|
256 | 256 | ?> |
257 | 257 | <option value="0"> 0 </option> |
258 | 258 | <?php } |
259 | 259 | // offer ticket quantities from the min to the max |
260 | - for ( $i = $min; $i <= $max; $i++) { |
|
260 | + for ($i = $min; $i <= $max; $i++) { |
|
261 | 261 | ?> |
262 | 262 | <option value="<?php echo $i; ?>"> <?php echo $i; ?> </option> |
263 | 263 | <?php } ?> |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | echo $ticket_status_display; |
270 | 270 | // depending on group reg we need to change the format for qty |
271 | - if ( $hidden_input_qty ) { |
|
271 | + if ($hidden_input_qty) { |
|
272 | 272 | ?> |
273 | 273 | <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="0" /> |
274 | 274 | <?php |
@@ -278,33 +278,33 @@ discard block |
||
278 | 278 | |
279 | 279 | </td> |
280 | 280 | </tr> |
281 | - <?php if ( $template_settings->show_ticket_details ) : ?> |
|
282 | - <tr class="tckt-slctr-tkt-details-tr <?php echo espresso_get_object_css_class( $ticket, '', 'details' );?>"> |
|
281 | + <?php if ($template_settings->show_ticket_details) : ?> |
|
282 | + <tr class="tckt-slctr-tkt-details-tr <?php echo espresso_get_object_css_class($ticket, '', 'details'); ?>"> |
|
283 | 283 | <td class="tckt-slctr-tkt-details-td" colspan="<?php echo $cols; ?>" > |
284 | 284 | <div id="<?php echo $ticket_details_css_id; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;"> |
285 | 285 | |
286 | 286 | <section class="tckt-slctr-tkt-details-sctn"> |
287 | - <h3><?php _e( 'Details', 'event_espresso' ); ?></h3> |
|
287 | + <h3><?php _e('Details', 'event_espresso'); ?></h3> |
|
288 | 288 | <p><?php echo $ticket->description(); ?></p> |
289 | 289 | |
290 | - <?php if ( $ticket_price !== 0 && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?> |
|
290 | + <?php if ($ticket_price !== 0 && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?> |
|
291 | 291 | <section class="tckt-slctr-tkt-price-sctn"> |
292 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __( 'Price', 'event_espresso' )); ?></h5> |
|
292 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __('Price', 'event_espresso')); ?></h5> |
|
293 | 293 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
294 | 294 | <table class="tckt-slctr-tkt-details-tbl"> |
295 | 295 | <thead> |
296 | 296 | <tr> |
297 | - <th class="ee-third-width"><span class="small-text"><?php _e( 'Name', 'event_espresso' ); ?></span></th> |
|
298 | - <th class="jst-cntr"><span class="small-text"><?php _e( 'Description', 'event_espresso' ); ?></span></th> |
|
299 | - <th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e( 'Amount', 'event_espresso' ); ?></span></th> |
|
297 | + <th class="ee-third-width"><span class="small-text"><?php _e('Name', 'event_espresso'); ?></span></th> |
|
298 | + <th class="jst-cntr"><span class="small-text"><?php _e('Description', 'event_espresso'); ?></span></th> |
|
299 | + <th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e('Amount', 'event_espresso'); ?></span></th> |
|
300 | 300 | </tr> |
301 | 301 | </thead> |
302 | 302 | <tbody> |
303 | - <?php if ( $ticket->base_price() instanceof EE_Price ) { ?> |
|
303 | + <?php if ($ticket->base_price() instanceof EE_Price) { ?> |
|
304 | 304 | <tr> |
305 | - <td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td> |
|
306 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td> |
|
307 | - <td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td> |
|
305 | + <td data-th="<?php _e('Name', 'event_espresso'); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td> |
|
306 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td> |
|
307 | + <td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td> |
|
308 | 308 | </tr> |
309 | 309 | <?php |
310 | 310 | $running_total = $ticket->base_price()->amount(); |
@@ -312,44 +312,44 @@ discard block |
||
312 | 312 | $running_total = 0; |
313 | 313 | } |
314 | 314 | // now add price modifiers |
315 | - foreach ( $ticket->price_modifiers() as $price_mod ) { ?> |
|
315 | + foreach ($ticket->price_modifiers() as $price_mod) { ?> |
|
316 | 316 | <tr> |
317 | - <td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td> |
|
318 | - <?php if ( $price_mod->is_percent() ) { ?> |
|
319 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td> |
|
317 | + <td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td> |
|
318 | + <?php if ($price_mod->is_percent()) { ?> |
|
319 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td> |
|
320 | 320 | <?php |
321 | - $new_sub_total = $running_total * ( $price_mod->amount() / 100 ); |
|
321 | + $new_sub_total = $running_total * ($price_mod->amount() / 100); |
|
322 | 322 | $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total; |
323 | 323 | ?> |
324 | 324 | <?php } else { ?> |
325 | 325 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?> |
326 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td> |
|
326 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td> |
|
327 | 327 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?> |
328 | 328 | <?php } ?> |
329 | - <td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $new_sub_total ); ?></td> |
|
329 | + <td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($new_sub_total); ?></td> |
|
330 | 330 | <?php $running_total += $new_sub_total; ?> |
331 | 331 | </tr> |
332 | 332 | <?php } ?> |
333 | - <?php if ( $ticket->taxable() ) { ?> |
|
333 | + <?php if ($ticket->taxable()) { ?> |
|
334 | 334 | <?php //$ticket_subtotal =$ticket->get_ticket_subtotal(); ?> |
335 | 335 | <tr> |
336 | - <td colspan="2" class="jst-rght small-text sbttl"><b><?php _e( 'subtotal', 'event_espresso' ); ?></b></td> |
|
337 | - <td data-th="<?php _e( 'subtotal', 'event_espresso' ); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency( $running_total ); ?></b></td> |
|
336 | + <td colspan="2" class="jst-rght small-text sbttl"><b><?php _e('subtotal', 'event_espresso'); ?></b></td> |
|
337 | + <td data-th="<?php _e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
|
338 | 338 | </tr> |
339 | 339 | |
340 | - <?php foreach ( $ticket->get_ticket_taxes_for_admin() as $tax ) { ?> |
|
340 | + <?php foreach ($ticket->get_ticket_taxes_for_admin() as $tax) { ?> |
|
341 | 341 | <tr> |
342 | - <td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td> |
|
343 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td> |
|
344 | - <?php $tax_amount = $running_total * ( $tax->amount() / 100 ); ?> |
|
345 | - <td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $tax_amount ); ?></td> |
|
342 | + <td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td> |
|
343 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td> |
|
344 | + <?php $tax_amount = $running_total * ($tax->amount() / 100); ?> |
|
345 | + <td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($tax_amount); ?></td> |
|
346 | 346 | <?php $running_total += $tax_amount; ?> |
347 | 347 | </tr> |
348 | 348 | <?php } ?> |
349 | 349 | <?php } ?> |
350 | 350 | <tr> |
351 | - <td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?></b></td> |
|
352 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency( $running_total ); ?></b></td> |
|
351 | + <td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?></b></td> |
|
352 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
|
353 | 353 | </tr> |
354 | 354 | </tbody> |
355 | 355 | </table> |
@@ -359,106 +359,106 @@ discard block |
||
359 | 359 | <?php } ?> |
360 | 360 | |
361 | 361 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
362 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __( 'Sale Dates', 'event_espresso' )); ?></h5> |
|
363 | - <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __( 'The dates when this option is available for purchase.', 'event_espresso' )); ?></span><br/> |
|
364 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __( 'Goes On Sale:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $date_format) . ' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $time_format ) ; ?><br/> |
|
365 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', __( 'Sales End:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $date_format ) . ' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $time_format ) ; ?><br/> |
|
362 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __('Sale Dates', 'event_espresso')); ?></h5> |
|
363 | + <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __('The dates when this option is available for purchase.', 'event_espresso')); ?></span><br/> |
|
364 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __('Goes On Sale:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format).' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime('TKT_start_date', $time_format); ?><br/> |
|
365 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_end', __('Sales End:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format).' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime('TKT_end_date', $time_format); ?><br/> |
|
366 | 366 | </section> |
367 | 367 | <br/> |
368 | 368 | |
369 | - <?php do_action( 'AHEE__ticket_selector_chart_template__after_ticket_date', $ticket ); ?> |
|
369 | + <?php do_action('AHEE__ticket_selector_chart_template__after_ticket_date', $ticket); ?> |
|
370 | 370 | |
371 | - <?php if ( $ticket->min() &&$ticket->max() ) { ?> |
|
371 | + <?php if ($ticket->min() && $ticket->max()) { ?> |
|
372 | 372 | <section class="tckt-slctr-tkt-quantities-sctn"> |
373 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __( 'Purchasable Quantities', 'event_espresso' )); ?></h5> |
|
374 | - <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __( 'The number of tickets that can be purchased per transaction (if available).', 'event_espresso' )); ?></span><br/> |
|
375 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __( 'Minimum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
376 | - <?php if ( $ticket->min() > $remaining ) { ?> <span class="important-notice small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __( 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso' )); ?></span><?php } ?><br/> |
|
373 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __('Purchasable Quantities', 'event_espresso')); ?></h5> |
|
374 | + <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __('The number of tickets that can be purchased per transaction (if available).', 'event_espresso')); ?></span><br/> |
|
375 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __('Minimum Qty:', 'event_espresso')); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
376 | + <?php if ($ticket->min() > $remaining) { ?> <span class="important-notice small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __('The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso')); ?></span><?php } ?><br/> |
|
377 | 377 | <?php //$max = min( $max, $max_atndz );?> |
378 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __( 'Maximum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->max() === EE_INF ? __( 'no limit', 'event_espresso' ) : max( $ticket->max(), 1 ); ?><br/> |
|
378 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __('Maximum Qty:', 'event_espresso')); ?></span><?php echo $ticket->max() === EE_INF ? __('no limit', 'event_espresso') : max($ticket->max(), 1); ?><br/> |
|
379 | 379 | </section> |
380 | 380 | <br/> |
381 | 381 | <?php } ?> |
382 | 382 | |
383 | - <?php if ( $ticket->uses() !== EE_INF && ( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE )) { ?> |
|
383 | + <?php if ($ticket->uses() !== EE_INF && ( ! defined('EE_DECAF') || EE_DECAF !== TRUE)) { ?> |
|
384 | 384 | <section class="tckt-slctr-tkt-uses-sctn"> |
385 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __( 'Event Date Ticket Uses', 'event_espresso' )); ?></h5> |
|
385 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __('Event Date Ticket Uses', 'event_espresso')); ?></h5> |
|
386 | 386 | <span class="drk-grey-text small-text no-bold"> - <?php |
387 | 387 | echo apply_filters( |
388 | 388 | 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
389 | 389 | sprintf( |
390 | - __( 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso' ), |
|
390 | + __('The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso'), |
|
391 | 391 | '<br/>', |
392 | 392 | '<strong>', |
393 | 393 | '</strong>' |
394 | 394 | ) |
395 | 395 | ); |
396 | 396 | ?></span><br/> |
397 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __( '# Datetimes:', 'event_espresso' )); ?></span><?php echo $ticket->uses();?><br/> |
|
397 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __('# Datetimes:', 'event_espresso')); ?></span><?php echo $ticket->uses(); ?><br/> |
|
398 | 398 | </section> |
399 | 399 | <?php } ?> |
400 | 400 | |
401 | 401 | <?php |
402 | - $datetimes = $ticket->datetimes_ordered( $event_is_expired, FALSE ); |
|
402 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, FALSE); |
|
403 | 403 | $chart_column_width = $template_settings->show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
404 | - if ( ! empty( $datetimes )) { ?> |
|
404 | + if ( ! empty($datetimes)) { ?> |
|
405 | 405 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
406 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __( 'Access', 'event_espresso' )); ?></h5> |
|
407 | - <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __( 'This option allows access to the following dates and times.', 'event_espresso' )); ?></span> |
|
406 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __('Access', 'event_espresso')); ?></h5> |
|
407 | + <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __('This option allows access to the following dates and times.', 'event_espresso')); ?></span> |
|
408 | 408 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
409 | 409 | <table class="tckt-slctr-tkt-details-tbl"> |
410 | 410 | <thead> |
411 | 411 | <tr> |
412 | 412 | <th class="tckt-slctr-tkt-details-date-th"> |
413 | - <span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Date ', 'event_espresso' )); ?></span> |
|
413 | + <span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Date ', 'event_espresso')); ?></span> |
|
414 | 414 | </th> |
415 | 415 | <th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>"> |
416 | - <span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e( 'Time ', 'event_espresso' ); ?></span> |
|
416 | + <span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e('Time ', 'event_espresso'); ?></span> |
|
417 | 417 | </th> |
418 | - <?php if ( $template_settings->show_ticket_sale_columns ) : ?> |
|
418 | + <?php if ($template_settings->show_ticket_sale_columns) : ?> |
|
419 | 419 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
420 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf( __( 'Sold', 'event_espresso' ), '<br/>' )); ?></span> |
|
420 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf(__('Sold', 'event_espresso'), '<br/>')); ?></span> |
|
421 | 421 | </th> |
422 | 422 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
423 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf( __( 'Remaining', 'event_espresso' ), '<br/>' )); ?></span> |
|
423 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf(__('Remaining', 'event_espresso'), '<br/>')); ?></span> |
|
424 | 424 | </th> |
425 | 425 | <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
426 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf( __( 'Total%sSold', 'event_espresso' ), '<br/>' )); ?></span> |
|
426 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf(__('Total%sSold', 'event_espresso'), '<br/>')); ?></span> |
|
427 | 427 | </th> |
428 | 428 | <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
429 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf( __( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' )); ?></span> |
|
429 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf(__('Total Spaces%sLeft', 'event_espresso'), '<br/>')); ?></span> |
|
430 | 430 | </th> |
431 | 431 | <?php endif; //end $template_settings->show_ticket_sale_columns conditional ?> |
432 | 432 | </tr> |
433 | 433 | </thead> |
434 | 434 | <tbody> |
435 | 435 | <?php |
436 | - foreach ( $datetimes as $datetime ) { |
|
437 | - if ( $datetime instanceof EE_Datetime ) { |
|
436 | + foreach ($datetimes as $datetime) { |
|
437 | + if ($datetime instanceof EE_Datetime) { |
|
438 | 438 | ?> |
439 | 439 | |
440 | 440 | <tr> |
441 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Event Date ', 'event_espresso' )); ?>" class="small-text"> |
|
441 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Event Date ', 'event_espresso')); ?>" class="small-text"> |
|
442 | 442 | <?php $datetime_name = $datetime->name(); ?> |
443 | - <?php echo ! empty( $datetime_name ) ? '<b>' . $datetime_name . '</b><br/>' : ''; ?> |
|
444 | - <?php echo $datetime->date_range( $date_format, __( ' to ', 'event_espresso' )); ?> |
|
443 | + <?php echo ! empty($datetime_name) ? '<b>'.$datetime_name.'</b><br/>' : ''; ?> |
|
444 | + <?php echo $datetime->date_range($date_format, __(' to ', 'event_espresso')); ?> |
|
445 | 445 | </td> |
446 | - <td data-th="<?php _e( 'Time ', 'event_espresso' ); ?>" class="cntr small-text"> |
|
447 | - <?php echo $datetime->time_range( $time_format, __( ' to ', 'event_espresso' )); ?> |
|
446 | + <td data-th="<?php _e('Time ', 'event_espresso'); ?>" class="cntr small-text"> |
|
447 | + <?php echo $datetime->time_range($time_format, __(' to ', 'event_espresso')); ?> |
|
448 | 448 | </td> |
449 | - <?php if ( $template_settings->show_ticket_sale_columns ) : ?> |
|
450 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __( 'Sold', 'event_espresso' )); ?>" class="cntr small-text"> |
|
449 | + <?php if ($template_settings->show_ticket_sale_columns) : ?> |
|
450 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __('Sold', 'event_espresso')); ?>" class="cntr small-text"> |
|
451 | 451 | <?php echo $ticket->sold(); ?> |
452 | 452 | </td> |
453 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __( 'Remaining', 'event_espresso' )); ?>" class="cntr small-text"> |
|
454 | - <?php echo $ticket->qty() === EE_INF ? '<span class="smaller-text">' . __( 'unlimited ', 'event_espresso' ) . '</span>' : $ticket->qty() - $ticket->sold(); ?> |
|
453 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __('Remaining', 'event_espresso')); ?>" class="cntr small-text"> |
|
454 | + <?php echo $ticket->qty() === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $ticket->qty() - $ticket->sold(); ?> |
|
455 | 455 | </td> |
456 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __( 'Total Sold', 'event_espresso' )); ?>" class="cntr small-text"> |
|
456 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __('Total Sold', 'event_espresso')); ?>" class="cntr small-text"> |
|
457 | 457 | <?php echo $datetime->sold(); ?> |
458 | 458 | </td> |
459 | - <?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">' . __( 'Sold Out', 'event_espresso' ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
460 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __( 'Total Spaces Left', 'event_espresso' )); ?>" class="cntr small-text"> |
|
461 | - <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' . __( 'unlimited ', 'event_espresso' ) . '</span>' : $tkts_left; ?> |
|
459 | + <?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">'.__('Sold Out', 'event_espresso').'</span>' : $datetime->spaces_remaining(); ?> |
|
460 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __('Total Spaces Left', 'event_espresso')); ?>" class="cntr small-text"> |
|
461 | + <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $tkts_left; ?> |
|
462 | 462 | </td> |
463 | 463 | <?php endif; //end $template_settings->show_ticket_sale_columns conditional ?> |
464 | 464 | </tr> |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | </div> |
477 | 477 | </td> |
478 | 478 | </tr> |
479 | - <?php endif; //end template_settings->show_ticket_details check?> |
|
479 | + <?php endif; //end template_settings->show_ticket_details check?> |
|
480 | 480 | <?php |
481 | 481 | $row++; |
482 | 482 | } |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | $ticket_row_html = ob_get_clean(); |
486 | 486 | // if there is only ONE ticket with a max qty of ONE, and it is free... then not much need for the ticket selector |
487 | 487 | $hide_ticket_selector = $ticket_count === 1 && $max_atndz === 1 && $ticket->is_free() ? true : false; |
488 | -$hide_ticket_selector = apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID ); |
|
489 | -remove_all_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector' ); |
|
488 | +$hide_ticket_selector = apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID); |
|
489 | +remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
490 | 490 | // EEH_Debug_Tools::printr( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ), 'display submit', __FILE__, __LINE__ ); |
491 | 491 | // EEH_Debug_Tools::printr( (string) $ticket_count, '$ticket_count', __FILE__, __LINE__ ); |
492 | 492 | // EEH_Debug_Tools::printr( (string) $max, '$max', __FILE__, __LINE__ ); |
@@ -500,20 +500,20 @@ discard block |
||
500 | 500 | * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
501 | 501 | * @param int $EVT_ID The Event ID |
502 | 502 | */ |
503 | -$anchor_id = apply_filters( 'FHEE__EE_Ticket_Selector__redirect_anchor_id', '#tkt-slctr-tbl-' . $EVT_ID, $EVT_ID ); |
|
504 | -if ( ! $hide_ticket_selector ) { |
|
503 | +$anchor_id = apply_filters('FHEE__EE_Ticket_Selector__redirect_anchor_id', '#tkt-slctr-tbl-'.$EVT_ID, $EVT_ID); |
|
504 | +if ( ! $hide_ticket_selector) { |
|
505 | 505 | ?> |
506 | 506 | <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv"> |
507 | 507 | |
508 | - <?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?> |
|
508 | + <?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?> |
|
509 | 509 | |
510 | 510 | <table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl"> |
511 | 511 | <thead> |
512 | 512 | <tr> |
513 | 513 | <th scope="col" class="ee-ticket-selector-ticket-details-th"> |
514 | - <?php echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID ) ); ?> |
|
514 | + <?php echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID)); ?> |
|
515 | 515 | </th> |
516 | - <?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?> |
|
516 | + <?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?> |
|
517 | 517 | <th scope="col" class="ee-ticket-selector-ticket-price-th cntr"> |
518 | 518 | <?php |
519 | 519 | /** |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @param string 'Price' The translatable text to display in the table header for price |
525 | 525 | * @param int $EVT_ID The Event ID |
526 | 526 | */ |
527 | - echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_price', __( 'Price', 'event_espresso' ), $EVT_ID ) ); |
|
527 | + echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_price', __('Price', 'event_espresso'), $EVT_ID)); |
|
528 | 528 | ?> |
529 | 529 | </th> |
530 | 530 | <?php } ?> |
@@ -538,77 +538,77 @@ discard block |
||
538 | 538 | * @param string 'Qty*' The translatable text to display in the table header for the Quantity of tickets |
539 | 539 | * @param int $EVT_ID The Event ID |
540 | 540 | */ |
541 | - echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_qty', __( 'Qty*', 'event_espresso' ), $EVT_ID ) ); |
|
541 | + echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_qty', __('Qty*', 'event_espresso'), $EVT_ID)); |
|
542 | 542 | ?> |
543 | 543 | </th> |
544 | 544 | </tr> |
545 | 545 | </thead> |
546 | 546 | <tbody> |
547 | - <?php echo $ticket_row_html;?> |
|
547 | + <?php echo $ticket_row_html; ?> |
|
548 | 548 | </tbody> |
549 | 549 | </table> |
550 | 550 | <?php |
551 | - if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) { |
|
552 | - if ( $tax_settings->prices_displayed_including_taxes ) { |
|
553 | - $ticket_price_includes_taxes = __( '* price includes taxes', 'event_espresso' ); |
|
551 | + if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
552 | + if ($tax_settings->prices_displayed_including_taxes) { |
|
553 | + $ticket_price_includes_taxes = __('* price includes taxes', 'event_espresso'); |
|
554 | 554 | } else { |
555 | - $ticket_price_includes_taxes = __( '* price does not include taxes', 'event_espresso' ); |
|
555 | + $ticket_price_includes_taxes = __('* price does not include taxes', 'event_espresso'); |
|
556 | 556 | } |
557 | - echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>'; |
|
557 | + echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>'; |
|
558 | 558 | } |
559 | 559 | ?> |
560 | 560 | |
561 | 561 | <input type="hidden" name="noheader" value="true" /> |
562 | - <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>" /> |
|
562 | + <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>" /> |
|
563 | 563 | <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>" /> |
564 | 564 | <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>" /> |
565 | 565 | <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>" /> |
566 | 566 | |
567 | 567 | <?php |
568 | -if ( $max_atndz > 0 ) { |
|
568 | +if ($max_atndz > 0) { |
|
569 | 569 | echo apply_filters( |
570 | 570 | 'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote', |
571 | 571 | '' |
572 | 572 | ); |
573 | 573 | } |
574 | -if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
575 | - add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' ); |
|
574 | +if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
575 | + add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true'); |
|
576 | 576 | } |
577 | -do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
577 | +do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
578 | 578 | ?> |
579 | 579 | |
580 | 580 | <?php |
581 | -} else if ( isset( $TKT_ID ) ) { |
|
582 | - add_filter( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', '__return_true' ); |
|
581 | +} else if (isset($TKT_ID)) { |
|
582 | + add_filter('FHEE__EE_Ticket_Selector__hide_ticket_selector', '__return_true'); |
|
583 | 583 | ?> |
584 | 584 | |
585 | 585 | <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/> |
586 | 586 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
587 | 587 | <input type="hidden" name="noheader" value="true"/> |
588 | -<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>"/> |
|
588 | +<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>"/> |
|
589 | 589 | <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>"/> |
590 | 590 | <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>"/> |
591 | 591 | <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>"/> |
592 | 592 | <?php |
593 | - if ( $ticket instanceof EE_Ticket ) { |
|
594 | - do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
593 | + if ($ticket instanceof EE_Ticket) { |
|
594 | + do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
|
595 | 595 | $ticket_description = $ticket->description(); |
596 | - $ticket_description .= ! empty( $ticket_description ) |
|
597 | - ? '<br />' . $ticket_status_display |
|
596 | + $ticket_description .= ! empty($ticket_description) |
|
597 | + ? '<br />'.$ticket_status_display |
|
598 | 598 | : $ticket_status_display; |
599 | - if ( ! strpos( $ticket_description, '<div' ) ) { |
|
599 | + if ( ! strpos($ticket_description, '<div')) { |
|
600 | 600 | $ticket_description = "<p>{$ticket_description}</p>"; |
601 | 601 | } |
602 | 602 | ?> |
603 | 603 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
604 | 604 | <div class="no-tkt-slctr-ticket-content-dv"> |
605 | 605 | <h5><?php echo $ticket->name(); ?></h5> |
606 | - <?php if ( ! empty( $ticket_description ) ) { ?> |
|
606 | + <?php if ( ! empty($ticket_description)) { ?> |
|
607 | 607 | <?php echo $ticket_description; ?> |
608 | 608 | <?php } ?> |
609 | 609 | </div> |
610 | 610 | <?php |
611 | - do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
611 | + do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | ?> |
@@ -466,38 +466,38 @@ discard block |
||
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
468 | 468 | public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
469 | - // registrations per event |
|
469 | + // registrations per event |
|
470 | 470 | $event_reg_count = array(); |
471 | 471 | // spaces left per event |
472 | 472 | $event_spaces_remaining = array(); |
473 | - // tickets left sorted by ID |
|
474 | - $tickets_remaining = array(); |
|
475 | - // registrations that have lost their space |
|
473 | + // tickets left sorted by ID |
|
474 | + $tickets_remaining = array(); |
|
475 | + // registrations that have lost their space |
|
476 | 476 | $ejected_registrations = array(); |
477 | 477 | foreach ( $registrations as $REG_ID => $registration ) { |
478 | 478 | if ( $registration->status_ID() === EEM_Registration::status_id_approved ) { |
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | $EVT_ID = $registration->event_ID(); |
482 | - $ticket = $registration->ticket(); |
|
483 | - if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
484 | - $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
485 | - } |
|
486 | - if ($tickets_remaining[$ticket->ID()] > 0) { |
|
487 | - if ( ! isset($event_reg_count[$EVT_ID])) { |
|
488 | - $event_reg_count[$EVT_ID] = 0; |
|
489 | - } |
|
490 | - $event_reg_count[$EVT_ID]++; |
|
491 | - if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
492 | - $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
493 | - } |
|
494 | - } |
|
482 | + $ticket = $registration->ticket(); |
|
483 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
484 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
485 | + } |
|
486 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
487 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
488 | + $event_reg_count[$EVT_ID] = 0; |
|
489 | + } |
|
490 | + $event_reg_count[$EVT_ID]++; |
|
491 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
492 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
493 | + } |
|
494 | + } |
|
495 | 495 | if ( |
496 | 496 | $revisit |
497 | 497 | && ( |
498 | - $tickets_remaining[$ticket->ID()] === 0 |
|
499 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
500 | - ) |
|
498 | + $tickets_remaining[$ticket->ID()] === 0 |
|
499 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
500 | + ) |
|
501 | 501 | ) { |
502 | 502 | $ejected_registrations[ $REG_ID ] = $registration->event(); |
503 | 503 | if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | 'layout_strategy' => new EE_Template_Layout( |
573 | 573 | array( |
574 | 574 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
575 | - . $this->_slug |
|
576 | - . DS |
|
577 | - . 'sold_out_events.template.php', |
|
575 | + . $this->_slug |
|
576 | + . DS |
|
577 | + . 'sold_out_events.template.php', |
|
578 | 578 | 'template_args' => apply_filters( |
579 | 579 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
580 | 580 | array( |
@@ -625,9 +625,9 @@ discard block |
||
625 | 625 | 'layout_strategy' => new EE_Template_Layout( |
626 | 626 | array( |
627 | 627 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
628 | - . $this->_slug |
|
629 | - . DS |
|
630 | - . 'sold_out_events.template.php', |
|
628 | + . $this->_slug |
|
629 | + . DS |
|
630 | + . 'sold_out_events.template.php', |
|
631 | 631 | 'template_args' => apply_filters( |
632 | 632 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
633 | 633 | array( |
@@ -679,9 +679,9 @@ discard block |
||
679 | 679 | 'layout_strategy' => new EE_Template_Layout( |
680 | 680 | array( |
681 | 681 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
682 | - . $this->_slug |
|
683 | - . DS |
|
684 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
682 | + . $this->_slug |
|
683 | + . DS |
|
684 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
685 | 685 | 'template_args' => apply_filters( |
686 | 686 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
687 | 687 | array( |
@@ -723,9 +723,9 @@ discard block |
||
723 | 723 | 'layout_strategy' => new EE_Template_Layout( |
724 | 724 | array( |
725 | 725 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
726 | - . $this->_slug |
|
727 | - . DS |
|
728 | - . 'no_payment_required.template.php', // layout_template |
|
726 | + . $this->_slug |
|
727 | + . DS |
|
728 | + . 'no_payment_required.template.php', // layout_template |
|
729 | 729 | 'template_args' => apply_filters( |
730 | 730 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
731 | 731 | array( |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
956 | 956 | } |
957 | 957 | $payment_methods_billing_info[ $payment_method->slug() |
958 | - . '-info' ] = $this->_payment_method_billing_info( |
|
958 | + . '-info' ] = $this->_payment_method_billing_info( |
|
959 | 959 | $payment_method |
960 | 960 | ); |
961 | 961 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | // fill form with attendee info if applicable |
1144 | 1144 | if ( |
1145 | 1145 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
1146 | - && $this->checkout->transaction_has_primary_registrant() |
|
1146 | + && $this->checkout->transaction_has_primary_registrant() |
|
1147 | 1147 | ) { |
1148 | 1148 | $payment_method_billing_form->populate_from_attendee( |
1149 | 1149 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | // and debug content |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
1155 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1155 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1156 | 1156 | ) { |
1157 | 1157 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1158 | 1158 | $payment_method_billing_form |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | } |
1328 | 1328 | // and debug content |
1329 | 1329 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1330 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1330 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1331 | 1331 | ) { |
1332 | 1332 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1333 | 1333 | $this->checkout->billing_form |
@@ -1461,8 +1461,8 @@ discard block |
||
1461 | 1461 | } |
1462 | 1462 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1463 | 1463 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1464 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1465 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1464 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1465 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1466 | 1466 | ) { |
1467 | 1467 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1468 | 1468 | array( |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | $payment_status = $payment->status(); |
1703 | 1703 | if ( |
1704 | 1704 | $payment_status === EEM_Payment::status_id_approved |
1705 | - || $payment_status === EEM_Payment::status_id_pending |
|
1705 | + || $payment_status === EEM_Payment::status_id_pending |
|
1706 | 1706 | ) { |
1707 | 1707 | return true; |
1708 | 1708 | } else { |
@@ -1888,8 +1888,8 @@ discard block |
||
1888 | 1888 | return false; |
1889 | 1889 | } |
1890 | 1890 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1891 | - instanceof |
|
1892 | - EE_Attendee |
|
1891 | + instanceof |
|
1892 | + EE_Attendee |
|
1893 | 1893 | ) { |
1894 | 1894 | EE_Error::add_error( |
1895 | 1895 | sprintf( |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | */ |
129 | - public function __construct( EE_Checkout $checkout ) { |
|
129 | + public function __construct(EE_Checkout $checkout) { |
|
130 | 130 | $this->_slug = 'payment_options'; |
131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
133 | 133 | $this->checkout = $checkout; |
134 | 134 | $this->_reset_success_message(); |
135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param null $line_item_display |
156 | 156 | */ |
157 | - public function set_line_item_display( $line_item_display ) { |
|
157 | + public function set_line_item_display($line_item_display) { |
|
158 | 158 | $this->line_item_display = $line_item_display; |
159 | 159 | } |
160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @param boolean $handle_IPN_in_this_request |
174 | 174 | */ |
175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | public function enqueue_styles_and_scripts() { |
209 | 209 | $transaction = $this->checkout->transaction; |
210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
215 | 215 | $type_obj = $payment_method->type_obj(); |
216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
219 | 219 | $billing_form->enqueue_js(); |
220 | 220 | } |
221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // $ 0.00 transactions (no payment required) |
241 | 241 | ! $this->checkout->payment_required() |
242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
244 | 244 | && ! $this->completed() |
245 | 245 | ) { |
246 | 246 | // and if so, then we no longer need the Payment Options step |
247 | - if ( $this->is_current_step() ) { |
|
247 | + if ($this->is_current_step()) { |
|
248 | 248 | $this->checkout->generate_reg_form = false; |
249 | 249 | } |
250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
250 | + $this->checkout->remove_reg_step($this->_slug); |
|
251 | 251 | // DEBUG LOG |
252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | // load EEM_Payment_Method |
256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
257 | 257 | // get all active payment methods |
258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
259 | 259 | $this->checkout->transaction, |
@@ -280,15 +280,15 @@ discard block |
||
280 | 280 | $insufficient_spaces_available = array(); |
281 | 281 | $reg_count = 0; |
282 | 282 | // loop thru registrations to gather info |
283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
285 | 285 | $registrations, |
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
288 | + foreach ($registrations as $REG_ID => $registration) { |
|
289 | 289 | // has this registration lost it's space ? |
290 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
291 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
290 | + if (isset($ejected_registrations[$REG_ID])) { |
|
291 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
292 | 292 | continue; |
293 | 293 | } |
294 | 294 | /** @var $registration EE_Registration */ |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | && $registration->status_ID() === EEM_Registration::status_id_approved |
301 | 301 | ) |
302 | 302 | ) { |
303 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) { |
|
303 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
304 | 304 | // add event to list of events that are sold out |
305 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
305 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
306 | 306 | do_action( |
307 | 307 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
308 | 308 | $registration->event(), |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | continue; |
312 | 312 | } |
313 | 313 | // event requires admin approval |
314 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
314 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
315 | 315 | // add event to list of events with pre-approval reg status |
316 | - $registrations_requiring_pre_approval[ $REG_ID ] = $registration; |
|
316 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
317 | 317 | do_action( |
318 | 318 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
319 | 319 | $registration->event(), |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | // are they allowed to pay now and is there monies owing? |
325 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
326 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
325 | + if ($registration->owes_monies_and_can_pay()) { |
|
326 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
327 | 327 | do_action( |
328 | 328 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
329 | 329 | $registration->event(), |
@@ -334,29 +334,29 @@ discard block |
||
334 | 334 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
335 | 335 | && $registration->ticket()->is_free() |
336 | 336 | ) { |
337 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
337 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | $subsections = array(); |
341 | 341 | // now decide which template to load |
342 | - if ( ! empty( $sold_out_events ) ) { |
|
343 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
342 | + if ( ! empty($sold_out_events)) { |
|
343 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
344 | 344 | } |
345 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
345 | + if ( ! empty($insufficient_spaces_available)) { |
|
346 | 346 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
347 | 347 | $insufficient_spaces_available |
348 | 348 | ); |
349 | 349 | } |
350 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
350 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
351 | 351 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
352 | 352 | $registrations_requiring_pre_approval |
353 | 353 | ); |
354 | 354 | } |
355 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
356 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
355 | + if ( ! empty($registrations_for_free_events)) { |
|
356 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
357 | 357 | } |
358 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
359 | - if ( $this->checkout->amount_owing > 0 ) { |
|
358 | + if ( ! empty($registrations_requiring_payment)) { |
|
359 | + if ($this->checkout->amount_owing > 0) { |
|
360 | 360 | // autoload Line_Item_Display classes |
361 | 361 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
362 | 362 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | /** @var EE_Line_Item $filtered_line_item_tree */ |
370 | 370 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
371 | 371 | EEH_Autoloader::register_line_item_display_autoloaders(); |
372 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
372 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
373 | 373 | $subsections['payment_options'] = $this->_display_payment_options( |
374 | 374 | $this->line_item_display->display_line_item( |
375 | 375 | $filtered_line_item_tree, |
376 | - array( 'registrations' => $registrations ) |
|
376 | + array('registrations' => $registrations) |
|
377 | 377 | ) |
378 | 378 | ); |
379 | 379 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
380 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
380 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
381 | 381 | } |
382 | 382 | } else { |
383 | 383 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return \EE_Line_Item_Filter_Collection |
409 | 409 | * @throws \EE_Error |
410 | 410 | */ |
411 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
411 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
412 | 412 | $line_item_filter_collection->add( |
413 | 413 | new EE_Billable_Line_Item_Filter( |
414 | 414 | EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | ) |
419 | 419 | ) |
420 | 420 | ); |
421 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
421 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
422 | 422 | return $line_item_filter_collection; |
423 | 423 | } |
424 | 424 | |
@@ -434,15 +434,15 @@ discard block |
||
434 | 434 | * @return \EE_Registration[] |
435 | 435 | * @throws \EE_Error |
436 | 436 | */ |
437 | - public static function remove_ejected_registrations( array $registrations ) { |
|
437 | + public static function remove_ejected_registrations(array $registrations) { |
|
438 | 438 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
439 | 439 | $registrations, |
440 | 440 | EE_Registry::instance()->SSN->checkout()->revisit |
441 | 441 | ); |
442 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
442 | + foreach ($registrations as $REG_ID => $registration) { |
|
443 | 443 | // has this registration lost it's space ? |
444 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
445 | - unset( $registrations[ $REG_ID ] ); |
|
444 | + if (isset($ejected_registrations[$REG_ID])) { |
|
445 | + unset($registrations[$REG_ID]); |
|
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @return array |
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
468 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
468 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
469 | 469 | // registrations per event |
470 | 470 | $event_reg_count = array(); |
471 | 471 | // spaces left per event |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | $tickets_remaining = array(); |
475 | 475 | // registrations that have lost their space |
476 | 476 | $ejected_registrations = array(); |
477 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
478 | - if ( $registration->status_ID() === EEM_Registration::status_id_approved ) { |
|
477 | + foreach ($registrations as $REG_ID => $registration) { |
|
478 | + if ($registration->status_ID() === EEM_Registration::status_id_approved) { |
|
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | $EVT_ID = $registration->event_ID(); |
@@ -496,13 +496,13 @@ discard block |
||
496 | 496 | $revisit |
497 | 497 | && ( |
498 | 498 | $tickets_remaining[$ticket->ID()] === 0 |
499 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
499 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
500 | 500 | ) |
501 | 501 | ) { |
502 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
503 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
502 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
503 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
504 | 504 | /** @type EE_Registration_Processor $registration_processor */ |
505 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
505 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
506 | 506 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
507 | 507 | $registration_processor->manually_update_registration_status( |
508 | 508 | $registration, |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | * @return void |
538 | 538 | */ |
539 | 539 | protected function _hide_reg_step_submit_button_if_revisit() { |
540 | - if ( $this->checkout->revisit ) { |
|
541 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
540 | + if ($this->checkout->revisit) { |
|
541 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | * @return \EE_Form_Section_Proper |
553 | 553 | * @throws \EE_Error |
554 | 554 | */ |
555 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
555 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
556 | 556 | // set some defaults |
557 | 557 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
558 | 558 | $sold_out_events = ''; |
559 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
559 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
560 | 560 | $sold_out_events .= EEH_HTML::li( |
561 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
561 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
562 | 562 | ); |
563 | 563 | } |
564 | 564 | return new EE_Form_Section_Proper( |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | * @return \EE_Form_Section_Proper |
606 | 606 | * @throws \EE_Error |
607 | 607 | */ |
608 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
608 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
609 | 609 | // set some defaults |
610 | 610 | $this->checkout->selected_method_of_payment = 'invoice'; |
611 | 611 | $insufficient_space_events = ''; |
612 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
613 | - if ( $event instanceof EE_Event ) { |
|
612 | + foreach ($insufficient_spaces_events_array as $event) { |
|
613 | + if ($event instanceof EE_Event) { |
|
614 | 614 | $insufficient_space_events .= EEH_HTML::li( |
615 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
615 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
616 | 616 | ); |
617 | 617 | } |
618 | 618 | } |
@@ -656,17 +656,17 @@ discard block |
||
656 | 656 | * @return \EE_Form_Section_Proper |
657 | 657 | * @throws \EE_Error |
658 | 658 | */ |
659 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
659 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
660 | 660 | $events_requiring_pre_approval = ''; |
661 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
662 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
663 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
661 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
662 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
663 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
664 | 664 | EEH_HTML::span( |
665 | 665 | '', |
666 | 666 | '', |
667 | 667 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
668 | 668 | ) |
669 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
669 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
670 | 670 | ); |
671 | 671 | } |
672 | 672 | } |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | 'template_args' => apply_filters( |
686 | 686 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
687 | 687 | array( |
688 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
688 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
689 | 689 | 'events_requiring_pre_approval_msg' => apply_filters( |
690 | 690 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
691 | 691 | __( |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | * @return \EE_Form_Section_Proper |
711 | 711 | * @throws \EE_Error |
712 | 712 | */ |
713 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
713 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
714 | 714 | // set some defaults |
715 | 715 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
716 | 716 | // generate no_payment_required form |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'ticket_count' => array(), |
735 | 735 | 'registrations_for_free_events' => $registrations_for_free_events, |
736 | 736 | 'no_payment_required_msg' => EEH_HTML::p( |
737 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
737 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
738 | 738 | ) |
739 | 739 | ) |
740 | 740 | ), |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * @return \EE_Form_Section_Proper |
754 | 754 | * @throws \EE_Error |
755 | 755 | */ |
756 | - private function _display_payment_options( $transaction_details = '' ) { |
|
756 | + private function _display_payment_options($transaction_details = '') { |
|
757 | 757 | // has method_of_payment been set by no-js user? |
758 | 758 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
759 | 759 | // build payment options form |
@@ -765,18 +765,18 @@ discard block |
||
765 | 765 | 'before_payment_options' => apply_filters( |
766 | 766 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
767 | 767 | new EE_Form_Section_Proper( |
768 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
768 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
769 | 769 | ) |
770 | 770 | ), |
771 | 771 | 'payment_options' => $this->_setup_payment_options(), |
772 | 772 | 'after_payment_options' => apply_filters( |
773 | 773 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
774 | 774 | new EE_Form_Section_Proper( |
775 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
775 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
776 | 776 | ) |
777 | 777 | ), |
778 | 778 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
779 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( false ) |
|
779 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(false) |
|
780 | 780 | ), |
781 | 781 | 'layout_strategy' => new EE_Template_Layout( |
782 | 782 | array( |
@@ -805,10 +805,10 @@ discard block |
||
805 | 805 | * @return \EE_Form_Section_Proper |
806 | 806 | * @throws \EE_Error |
807 | 807 | */ |
808 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
808 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
809 | 809 | return new EE_Form_Section_Proper( |
810 | 810 | array( |
811 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
811 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
812 | 812 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
813 | 813 | 'subsections' => array( |
814 | 814 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -840,16 +840,16 @@ discard block |
||
840 | 840 | * @access protected |
841 | 841 | * @param array $registrations |
842 | 842 | */ |
843 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
843 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
844 | 844 | $payments = array(); |
845 | - foreach ( $registrations as $registration ) { |
|
846 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
845 | + foreach ($registrations as $registration) { |
|
846 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
847 | 847 | $payments += $registration->registration_payments(); |
848 | 848 | } |
849 | 849 | } |
850 | - if ( ! empty( $payments ) ) { |
|
851 | - foreach ( $payments as $payment ) { |
|
852 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
850 | + if ( ! empty($payments)) { |
|
851 | + foreach ($payments as $payment) { |
|
852 | + if ($payment instanceof EE_Registration_Payment) { |
|
853 | 853 | $this->checkout->amount_owing -= $payment->amount(); |
854 | 854 | } |
855 | 855 | } |
@@ -865,11 +865,11 @@ discard block |
||
865 | 865 | * @param bool $force_reset |
866 | 866 | * @return void |
867 | 867 | */ |
868 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
868 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
869 | 869 | $reset_payment_method = $force_reset |
870 | 870 | ? true |
871 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
872 | - if ( $reset_payment_method ) { |
|
871 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
872 | + if ($reset_payment_method) { |
|
873 | 873 | $this->checkout->selected_method_of_payment = null; |
874 | 874 | $this->checkout->payment_method = null; |
875 | 875 | $this->checkout->billing_form = null; |
@@ -888,12 +888,12 @@ discard block |
||
888 | 888 | * @param string $selected_method_of_payment |
889 | 889 | * @return void |
890 | 890 | */ |
891 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
892 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
891 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
892 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
893 | 893 | ? $selected_method_of_payment |
894 | 894 | : $this->checkout->selected_method_of_payment; |
895 | 895 | EE_Registry::instance()->SSN->set_session_data( |
896 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
896 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
897 | 897 | ); |
898 | 898 | } |
899 | 899 | |
@@ -909,19 +909,19 @@ discard block |
||
909 | 909 | // load payment method classes |
910 | 910 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
911 | 911 | // switch up header depending on number of available payment methods |
912 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
912 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
913 | 913 | ? apply_filters( |
914 | 914 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
915 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
915 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
916 | 916 | ) |
917 | 917 | : apply_filters( |
918 | 918 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
919 | - __( 'Method of Payment', 'event_espresso' ) |
|
919 | + __('Method of Payment', 'event_espresso') |
|
920 | 920 | ); |
921 | 921 | $available_payment_methods = array( |
922 | 922 | // display the "Payment Method" header |
923 | 923 | 'payment_method_header' => new EE_Form_Section_HTML( |
924 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
924 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
925 | 925 | ) |
926 | 926 | ); |
927 | 927 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -930,32 +930,32 @@ discard block |
||
930 | 930 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
931 | 931 | $payment_methods_billing_info = array( |
932 | 932 | new EE_Form_Section_HTML( |
933 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
933 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
934 | 934 | ) |
935 | 935 | ); |
936 | 936 | // loop through payment methods |
937 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
938 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
937 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
938 | + if ($payment_method instanceof EE_Payment_Method) { |
|
939 | 939 | $payment_method_button = EEH_HTML::img( |
940 | 940 | $payment_method->button_url(), |
941 | 941 | $payment_method->name(), |
942 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
942 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
943 | 943 | 'spco-payment-method-btn-img' |
944 | 944 | ); |
945 | 945 | // check if any payment methods are set as default |
946 | 946 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
947 | 947 | if ( |
948 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
949 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
948 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
949 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
950 | 950 | ) { |
951 | 951 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
952 | 952 | $this->_save_selected_method_of_payment(); |
953 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
953 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
954 | 954 | } else { |
955 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
955 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
956 | 956 | } |
957 | - $payment_methods_billing_info[ $payment_method->slug() |
|
958 | - . '-info' ] = $this->_payment_method_billing_info( |
|
957 | + $payment_methods_billing_info[$payment_method->slug() |
|
958 | + . '-info'] = $this->_payment_method_billing_info( |
|
959 | 959 | $payment_method |
960 | 960 | ); |
961 | 961 | } |
@@ -985,12 +985,12 @@ discard block |
||
985 | 985 | * @return EE_Payment_Method[] |
986 | 986 | */ |
987 | 987 | protected function _get_available_payment_methods() { |
988 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
988 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
989 | 989 | return $this->checkout->available_payment_methods; |
990 | 990 | } |
991 | 991 | $available_payment_methods = array(); |
992 | 992 | // load EEM_Payment_Method |
993 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
993 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
994 | 994 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
995 | 995 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
996 | 996 | // get all active payment methods |
@@ -998,9 +998,9 @@ discard block |
||
998 | 998 | $this->checkout->transaction, |
999 | 999 | EEM_Payment_Method::scope_cart |
1000 | 1000 | ); |
1001 | - foreach ( $payment_methods as $payment_method ) { |
|
1002 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
1003 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
1001 | + foreach ($payment_methods as $payment_method) { |
|
1002 | + if ($payment_method instanceof EE_Payment_Method) { |
|
1003 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | return $available_payment_methods; |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | * @param array $available_payment_method_options |
1016 | 1016 | * @return \EE_Form_Section_Proper |
1017 | 1017 | */ |
1018 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
1018 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
1019 | 1019 | // generate inputs |
1020 | 1020 | return new EE_Form_Section_Proper( |
1021 | 1021 | array( |
1022 | 1022 | 'html_id' => 'ee-available-payment-method-inputs', |
1023 | 1023 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1024 | 1024 | 'subsections' => array( |
1025 | - '' => new EE_Radio_Button_Input ( |
|
1025 | + '' => new EE_Radio_Button_Input( |
|
1026 | 1026 | $available_payment_method_options, |
1027 | 1027 | array( |
1028 | 1028 | 'html_name' => 'selected_method_of_payment', |
@@ -1047,28 +1047,28 @@ discard block |
||
1047 | 1047 | * @return \EE_Form_Section_Proper |
1048 | 1048 | * @throws \EE_Error |
1049 | 1049 | */ |
1050 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
1050 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
1051 | 1051 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
1052 | 1052 | ? true |
1053 | 1053 | : false; |
1054 | 1054 | // generate the billing form for payment method |
1055 | 1055 | $billing_form = $currently_selected |
1056 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
1056 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
1057 | 1057 | : new EE_Form_Section_HTML(); |
1058 | 1058 | $this->checkout->billing_form = $currently_selected |
1059 | 1059 | ? $billing_form |
1060 | 1060 | : $this->checkout->billing_form; |
1061 | 1061 | // it's all in the details |
1062 | 1062 | $info_html = EEH_HTML::h3( |
1063 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
1063 | + __('Important information regarding your payment', 'event_espresso'), |
|
1064 | 1064 | '', |
1065 | 1065 | 'spco-payment-method-hdr' |
1066 | 1066 | ); |
1067 | 1067 | // add some info regarding the step, either from what's saved in the admin, |
1068 | 1068 | // or a default string depending on whether the PM has a billing form or not |
1069 | - if ( $payment_method->description() ) { |
|
1069 | + if ($payment_method->description()) { |
|
1070 | 1070 | $payment_method_info = $payment_method->description(); |
1071 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1071 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
1072 | 1072 | $payment_method_info = sprintf( |
1073 | 1073 | __( |
1074 | 1074 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | ); |
1079 | 1079 | } else { |
1080 | 1080 | $payment_method_info = sprintf( |
1081 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
1081 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
1082 | 1082 | $this->submit_button_text() |
1083 | 1083 | ); |
1084 | 1084 | } |
@@ -1092,13 +1092,13 @@ discard block |
||
1092 | 1092 | ); |
1093 | 1093 | return new EE_Form_Section_Proper( |
1094 | 1094 | array( |
1095 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
1095 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
1096 | 1096 | 'html_class' => 'spco-payment-method-info-dv', |
1097 | 1097 | // only display the selected or default PM |
1098 | 1098 | 'html_style' => $currently_selected ? '' : 'display:none;', |
1099 | 1099 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1100 | 1100 | 'subsections' => array( |
1101 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
1101 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
1102 | 1102 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
1103 | 1103 | ) |
1104 | 1104 | ) |
@@ -1116,15 +1116,15 @@ discard block |
||
1116 | 1116 | */ |
1117 | 1117 | public function get_billing_form_html_for_payment_method() { |
1118 | 1118 | // how have they chosen to pay? |
1119 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1119 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1120 | 1120 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1121 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1121 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1122 | 1122 | return false; |
1123 | 1123 | } |
1124 | - if ( apply_filters( |
|
1124 | + if (apply_filters( |
|
1125 | 1125 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1126 | 1126 | false |
1127 | - ) ) { |
|
1127 | + )) { |
|
1128 | 1128 | EE_Error::add_success( |
1129 | 1129 | apply_filters( |
1130 | 1130 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | ); |
1140 | 1140 | } |
1141 | 1141 | // now generate billing form for selected method of payment |
1142 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1142 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1143 | 1143 | // fill form with attendee info if applicable |
1144 | 1144 | if ( |
1145 | 1145 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1161,10 +1161,10 @@ discard block |
||
1161 | 1161 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
1162 | 1162 | ? $payment_method_billing_form->get_html() |
1163 | 1163 | : ''; |
1164 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
1164 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
1165 | 1165 | // localize validation rules for main form |
1166 | 1166 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
1167 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1167 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1168 | 1168 | return true; |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1178,18 +1178,18 @@ discard block |
||
1178 | 1178 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
1179 | 1179 | * @throws \EE_Error |
1180 | 1180 | */ |
1181 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1181 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1182 | 1182 | $billing_form = $payment_method->type_obj()->billing_form( |
1183 | 1183 | $this->checkout->transaction, |
1184 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1184 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1185 | 1185 | ); |
1186 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1186 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1187 | 1187 | if ( |
1188 | 1188 | apply_filters( |
1189 | 1189 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1190 | 1190 | false |
1191 | 1191 | ) |
1192 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1192 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1193 | 1193 | ) { |
1194 | 1194 | EE_Error::add_success( |
1195 | 1195 | apply_filters( |
@@ -1231,15 +1231,15 @@ discard block |
||
1231 | 1231 | $request_param = 'selected_method_of_payment' |
1232 | 1232 | ) { |
1233 | 1233 | // is selected_method_of_payment set in the request ? |
1234 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1235 | - if ( $selected_method_of_payment ) { |
|
1234 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1235 | + if ($selected_method_of_payment) { |
|
1236 | 1236 | // sanitize it |
1237 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1238 | - ? array_shift( $selected_method_of_payment ) |
|
1237 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1238 | + ? array_shift($selected_method_of_payment) |
|
1239 | 1239 | : $selected_method_of_payment; |
1240 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1240 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1241 | 1241 | // store it in the session so that it's available for all subsequent requests including AJAX |
1242 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1242 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1243 | 1243 | } else { |
1244 | 1244 | // or is is set in the session ? |
1245 | 1245 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | ); |
1248 | 1248 | } |
1249 | 1249 | // do ya really really gotta have it? |
1250 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1250 | + if (empty($selected_method_of_payment) && $required) { |
|
1251 | 1251 | EE_Error::add_error( |
1252 | 1252 | sprintf( |
1253 | 1253 | __( |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | ), |
1257 | 1257 | '<br/>', |
1258 | 1258 | '<br/>', |
1259 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1259 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1260 | 1260 | ), |
1261 | 1261 | __FILE__, |
1262 | 1262 | __FUNCTION__, |
@@ -1283,13 +1283,13 @@ discard block |
||
1283 | 1283 | * @throws \EE_Error |
1284 | 1284 | */ |
1285 | 1285 | public function switch_payment_method() { |
1286 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1286 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1287 | 1287 | return false; |
1288 | 1288 | } |
1289 | - if ( apply_filters( |
|
1289 | + if (apply_filters( |
|
1290 | 1290 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1291 | 1291 | false |
1292 | - ) ) { |
|
1292 | + )) { |
|
1293 | 1293 | EE_Error::add_success( |
1294 | 1294 | apply_filters( |
1295 | 1295 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | ); |
1305 | 1305 | } |
1306 | 1306 | // generate billing form for selected method of payment if it hasn't been done already |
1307 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1307 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1308 | 1308 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1309 | 1309 | $this->checkout->payment_method |
1310 | 1310 | ); |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | ); |
1327 | 1327 | } |
1328 | 1328 | // and debug content |
1329 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1329 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1330 | 1330 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1331 | 1331 | ) { |
1332 | 1332 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1334,15 +1334,15 @@ discard block |
||
1334 | 1334 | ); |
1335 | 1335 | } |
1336 | 1336 | // get html and validation rules for form |
1337 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1337 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1338 | 1338 | $this->checkout->json_response->set_return_data( |
1339 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1339 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1340 | 1340 | ); |
1341 | 1341 | // localize validation rules for main form |
1342 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1343 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1342 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1343 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1344 | 1344 | } else { |
1345 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1345 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1346 | 1346 | } |
1347 | 1347 | //prevents advancement to next step |
1348 | 1348 | $this->checkout->continue_reg = false; |
@@ -1359,12 +1359,12 @@ discard block |
||
1359 | 1359 | */ |
1360 | 1360 | protected function _verify_payment_method_is_set() { |
1361 | 1361 | // generate billing form for selected method of payment if it hasn't been done already |
1362 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1362 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1363 | 1363 | // how have they chosen to pay? |
1364 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1364 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1365 | 1365 | } |
1366 | 1366 | // verify payment method |
1367 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1367 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1368 | 1368 | // get payment method for selected method of payment |
1369 | 1369 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1370 | 1370 | } |
@@ -1383,25 +1383,25 @@ discard block |
||
1383 | 1383 | * @throws \EE_Error |
1384 | 1384 | */ |
1385 | 1385 | public function save_payer_details_via_ajax() { |
1386 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1386 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1387 | 1387 | return; |
1388 | 1388 | } |
1389 | 1389 | // generate billing form for selected method of payment if it hasn't been done already |
1390 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1390 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1391 | 1391 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1392 | 1392 | $this->checkout->payment_method |
1393 | 1393 | ); |
1394 | 1394 | } |
1395 | 1395 | // generate primary attendee from payer info if applicable |
1396 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1396 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1397 | 1397 | $attendee = $this->_create_attendee_from_request_data(); |
1398 | - if ( $attendee instanceof EE_Attendee ) { |
|
1399 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1400 | - if ( $registration->is_primary_registrant() ) { |
|
1398 | + if ($attendee instanceof EE_Attendee) { |
|
1399 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1400 | + if ($registration->is_primary_registrant()) { |
|
1401 | 1401 | $this->checkout->primary_attendee_obj = $attendee; |
1402 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1403 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1404 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1402 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1403 | + $registration->set_attendee_id($attendee->ID()); |
|
1404 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1405 | 1405 | } |
1406 | 1406 | } |
1407 | 1407 | } |
@@ -1419,50 +1419,50 @@ discard block |
||
1419 | 1419 | */ |
1420 | 1420 | protected function _create_attendee_from_request_data() { |
1421 | 1421 | // get State ID |
1422 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1423 | - if ( ! empty( $STA_ID ) ) { |
|
1422 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1423 | + if ( ! empty($STA_ID)) { |
|
1424 | 1424 | // can we get state object from name ? |
1425 | - EE_Registry::instance()->load_model( 'State' ); |
|
1426 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1427 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1425 | + EE_Registry::instance()->load_model('State'); |
|
1426 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1427 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1428 | 1428 | } |
1429 | 1429 | // get Country ISO |
1430 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1431 | - if ( ! empty( $CNT_ISO ) ) { |
|
1430 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1431 | + if ( ! empty($CNT_ISO)) { |
|
1432 | 1432 | // can we get country object from name ? |
1433 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1433 | + EE_Registry::instance()->load_model('Country'); |
|
1434 | 1434 | $country = EEM_Country::instance()->get_col( |
1435 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1435 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1436 | 1436 | 'CNT_ISO' |
1437 | 1437 | ); |
1438 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1438 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1439 | 1439 | } |
1440 | 1440 | // grab attendee data |
1441 | 1441 | $attendee_data = array( |
1442 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1443 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1444 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1445 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1446 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1447 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1442 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1443 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1444 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1445 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1446 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1447 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1448 | 1448 | 'STA_ID' => $STA_ID, |
1449 | 1449 | 'CNT_ISO' => $CNT_ISO, |
1450 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1451 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1450 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1451 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1452 | 1452 | ); |
1453 | 1453 | // validate the email address since it is the most important piece of info |
1454 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1454 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1455 | 1455 | EE_Error::add_error( |
1456 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1456 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1457 | 1457 | __FILE__, |
1458 | 1458 | __FUNCTION__, |
1459 | 1459 | __LINE__ |
1460 | 1460 | ); |
1461 | 1461 | } |
1462 | 1462 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1463 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1464 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1465 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1463 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1464 | + && ! empty($attendee_data['ATT_lname']) |
|
1465 | + && ! empty($attendee_data['ATT_email']) |
|
1466 | 1466 | ) { |
1467 | 1467 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1468 | 1468 | array( |
@@ -1471,19 +1471,19 @@ discard block |
||
1471 | 1471 | 'ATT_email' => $attendee_data['ATT_email'] |
1472 | 1472 | ) |
1473 | 1473 | ); |
1474 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1474 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1475 | 1475 | return $existing_attendee; |
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | // no existing attendee? kk let's create a new one |
1479 | 1479 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1480 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1480 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1481 | 1481 | ? $attendee_data['ATT_fname'] |
1482 | 1482 | : $attendee_data['ATT_email']; |
1483 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1483 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1484 | 1484 | ? $attendee_data['ATT_lname'] |
1485 | 1485 | : $attendee_data['ATT_email']; |
1486 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1486 | + return EE_Attendee::new_instance($attendee_data); |
|
1487 | 1487 | } |
1488 | 1488 | |
1489 | 1489 | |
@@ -1501,26 +1501,26 @@ discard block |
||
1501 | 1501 | // how have they chosen to pay? |
1502 | 1502 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1503 | 1503 | ? 'no_payment_required' |
1504 | - : $this->_get_selected_method_of_payment( true ); |
|
1504 | + : $this->_get_selected_method_of_payment(true); |
|
1505 | 1505 | // choose your own adventure based on method_of_payment |
1506 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1506 | + switch ($this->checkout->selected_method_of_payment) { |
|
1507 | 1507 | |
1508 | 1508 | case 'events_sold_out' : |
1509 | 1509 | $this->checkout->redirect = true; |
1510 | 1510 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1511 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1511 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1512 | 1512 | // mark this reg step as completed |
1513 | 1513 | $this->set_completed(); |
1514 | 1514 | return false; |
1515 | 1515 | break; |
1516 | 1516 | |
1517 | 1517 | case 'payments_closed' : |
1518 | - if ( apply_filters( |
|
1518 | + if (apply_filters( |
|
1519 | 1519 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1520 | 1520 | false |
1521 | - ) ) { |
|
1521 | + )) { |
|
1522 | 1522 | EE_Error::add_success( |
1523 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1523 | + __('no payment required at this time.', 'event_espresso'), |
|
1524 | 1524 | __FILE__, |
1525 | 1525 | __FUNCTION__, |
1526 | 1526 | __LINE__ |
@@ -1532,12 +1532,12 @@ discard block |
||
1532 | 1532 | break; |
1533 | 1533 | |
1534 | 1534 | case 'no_payment_required' : |
1535 | - if ( apply_filters( |
|
1535 | + if (apply_filters( |
|
1536 | 1536 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1537 | 1537 | false |
1538 | - ) ) { |
|
1538 | + )) { |
|
1539 | 1539 | EE_Error::add_success( |
1540 | - __( 'no payment required.', 'event_espresso' ), |
|
1540 | + __('no payment required.', 'event_espresso'), |
|
1541 | 1541 | __FILE__, |
1542 | 1542 | __FUNCTION__, |
1543 | 1543 | __LINE__ |
@@ -1557,15 +1557,15 @@ discard block |
||
1557 | 1557 | EE_Registry::instance()->SSN->checkout()->revisit |
1558 | 1558 | ); |
1559 | 1559 | // calculate difference between the two arrays |
1560 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
1561 | - if ( empty( $registrations ) ) { |
|
1560 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
1561 | + if (empty($registrations)) { |
|
1562 | 1562 | $this->_redirect_because_event_sold_out(); |
1563 | 1563 | return false; |
1564 | 1564 | } |
1565 | 1565 | $payment_successful = $this->_process_payment(); |
1566 | - if ( $payment_successful ) { |
|
1566 | + if ($payment_successful) { |
|
1567 | 1567 | $this->checkout->continue_reg = true; |
1568 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1568 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1569 | 1569 | } else { |
1570 | 1570 | $this->checkout->continue_reg = false; |
1571 | 1571 | } |
@@ -1586,10 +1586,10 @@ discard block |
||
1586 | 1586 | $this->checkout->continue_reg = false; |
1587 | 1587 | // set redirect URL |
1588 | 1588 | $this->checkout->redirect_url = add_query_arg( |
1589 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1589 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1590 | 1590 | $this->checkout->current_step->reg_step_url() |
1591 | 1591 | ); |
1592 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1592 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | |
@@ -1602,8 +1602,8 @@ discard block |
||
1602 | 1602 | * @return void |
1603 | 1603 | * @throws \EE_Error |
1604 | 1604 | */ |
1605 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1606 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1605 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1606 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1607 | 1607 | case EE_PMT_Base::offsite : |
1608 | 1608 | break; |
1609 | 1609 | case EE_PMT_Base::onsite : |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | public function update_reg_step() { |
1627 | 1627 | $success = true; |
1628 | 1628 | // if payment required |
1629 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1629 | + if ($this->checkout->transaction->total() > 0) { |
|
1630 | 1630 | do_action( |
1631 | 1631 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1632 | 1632 | $this->checkout->transaction |
@@ -1634,13 +1634,13 @@ discard block |
||
1634 | 1634 | // attempt payment via payment method |
1635 | 1635 | $success = $this->process_reg_step(); |
1636 | 1636 | } |
1637 | - if ( $success && ! $this->checkout->redirect ) { |
|
1637 | + if ($success && ! $this->checkout->redirect) { |
|
1638 | 1638 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1639 | 1639 | $this->checkout->transaction->ID() |
1640 | 1640 | ); |
1641 | 1641 | // set return URL |
1642 | 1642 | $this->checkout->redirect_url = add_query_arg( |
1643 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1643 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1644 | 1644 | $this->checkout->thank_you_page_url |
1645 | 1645 | ); |
1646 | 1646 | } |
@@ -1660,28 +1660,28 @@ discard block |
||
1660 | 1660 | // clear any previous errors related to not selecting a payment method |
1661 | 1661 | // EE_Error::overwrite_errors(); |
1662 | 1662 | // ya gotta make a choice man |
1663 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1663 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1664 | 1664 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1665 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1665 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1666 | 1666 | ); |
1667 | 1667 | return false; |
1668 | 1668 | } |
1669 | 1669 | // get EE_Payment_Method object |
1670 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1670 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1671 | 1671 | return false; |
1672 | 1672 | } |
1673 | 1673 | // setup billing form |
1674 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1674 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1675 | 1675 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1676 | 1676 | $this->checkout->payment_method |
1677 | 1677 | ); |
1678 | 1678 | // bad billing form ? |
1679 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1679 | + if ( ! $this->_billing_form_is_valid()) { |
|
1680 | 1680 | return false; |
1681 | 1681 | } |
1682 | 1682 | } |
1683 | 1683 | // ensure primary registrant has been fully processed |
1684 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1684 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1685 | 1685 | return false; |
1686 | 1686 | } |
1687 | 1687 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1689,12 +1689,12 @@ discard block |
||
1689 | 1689 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1690 | 1690 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1691 | 1691 | // attempt payment |
1692 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1692 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1693 | 1693 | // process results |
1694 | - $payment = $this->_validate_payment( $payment ); |
|
1695 | - $payment = $this->_post_payment_processing( $payment ); |
|
1694 | + $payment = $this->_validate_payment($payment); |
|
1695 | + $payment = $this->_post_payment_processing($payment); |
|
1696 | 1696 | // verify payment |
1697 | - if ( $payment instanceof EE_Payment ) { |
|
1697 | + if ($payment instanceof EE_Payment) { |
|
1698 | 1698 | // store that for later |
1699 | 1699 | $this->checkout->payment = $payment; |
1700 | 1700 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1708,7 +1708,7 @@ discard block |
||
1708 | 1708 | } else { |
1709 | 1709 | return false; |
1710 | 1710 | } |
1711 | - } else if ( $payment === true ) { |
|
1711 | + } else if ($payment === true) { |
|
1712 | 1712 | // please note that offline payment methods will NOT make a payment, |
1713 | 1713 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1714 | 1714 | $this->checkout->payment = $payment; |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | ); |
1734 | 1734 | $html = $payment_method_billing_info->get_html(); |
1735 | 1735 | $html .= $this->checkout->redirect_form; |
1736 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1736 | + EE_Registry::instance()->REQ->add_output($html); |
|
1737 | 1737 | return true; |
1738 | 1738 | } |
1739 | 1739 | |
@@ -1747,28 +1747,28 @@ discard block |
||
1747 | 1747 | * @throws \EE_Error |
1748 | 1748 | */ |
1749 | 1749 | private function _billing_form_is_valid() { |
1750 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1750 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1751 | 1751 | return true; |
1752 | 1752 | } |
1753 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1754 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1753 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1754 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1755 | 1755 | $this->checkout->billing_form->receive_form_submission(); |
1756 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1756 | + if ($this->checkout->billing_form->is_valid()) { |
|
1757 | 1757 | return true; |
1758 | 1758 | } |
1759 | 1759 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1760 | 1760 | $error_strings = array(); |
1761 | - foreach ( $validation_errors as $validation_error ) { |
|
1762 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1761 | + foreach ($validation_errors as $validation_error) { |
|
1762 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1763 | 1763 | $form_section = $validation_error->get_form_section(); |
1764 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1764 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1765 | 1765 | $label = $form_section->html_label_text(); |
1766 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1766 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1767 | 1767 | $label = $form_section->name(); |
1768 | 1768 | } else { |
1769 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1769 | + $label = __('Validation Error', 'event_espresso'); |
|
1770 | 1770 | } |
1771 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1771 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1772 | 1772 | } |
1773 | 1773 | } |
1774 | 1774 | EE_Error::add_error( |
@@ -1778,7 +1778,7 @@ discard block |
||
1778 | 1778 | 'event_espresso' |
1779 | 1779 | ), |
1780 | 1780 | '<br/>', |
1781 | - implode( '<br/>', $error_strings ) |
|
1781 | + implode('<br/>', $error_strings) |
|
1782 | 1782 | ), |
1783 | 1783 | __FILE__, |
1784 | 1784 | __FUNCTION__, |
@@ -1797,7 +1797,7 @@ discard block |
||
1797 | 1797 | } |
1798 | 1798 | } else { |
1799 | 1799 | EE_Error::add_error( |
1800 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1800 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1801 | 1801 | __FILE__, |
1802 | 1802 | __FUNCTION__, |
1803 | 1803 | __LINE__ |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | // save the TXN ( which clears cached copy of primary_registration) |
1837 | 1837 | $this->checkout->transaction->save(); |
1838 | 1838 | // grab TXN ID and save it to the primary_registration |
1839 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1839 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1840 | 1840 | // save what we have so far |
1841 | 1841 | $primary_registration->save(); |
1842 | 1842 | return true; |
@@ -1854,7 +1854,7 @@ discard block |
||
1854 | 1854 | private function _capture_primary_registration_data_from_billing_form() { |
1855 | 1855 | // convert billing form data into an attendee |
1856 | 1856 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1857 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1857 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1858 | 1858 | EE_Error::add_error( |
1859 | 1859 | sprintf( |
1860 | 1860 | __( |
@@ -1862,7 +1862,7 @@ discard block |
||
1862 | 1862 | 'event_espresso' |
1863 | 1863 | ), |
1864 | 1864 | '<br/>', |
1865 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1865 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1866 | 1866 | ), |
1867 | 1867 | __FILE__, |
1868 | 1868 | __FUNCTION__, |
@@ -1871,7 +1871,7 @@ discard block |
||
1871 | 1871 | return false; |
1872 | 1872 | } |
1873 | 1873 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1874 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1874 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1875 | 1875 | EE_Error::add_error( |
1876 | 1876 | sprintf( |
1877 | 1877 | __( |
@@ -1879,7 +1879,7 @@ discard block |
||
1879 | 1879 | 'event_espresso' |
1880 | 1880 | ), |
1881 | 1881 | '<br/>', |
1882 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1882 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1883 | 1883 | ), |
1884 | 1884 | __FILE__, |
1885 | 1885 | __FUNCTION__, |
@@ -1887,7 +1887,7 @@ discard block |
||
1887 | 1887 | ); |
1888 | 1888 | return false; |
1889 | 1889 | } |
1890 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1890 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1891 | 1891 | instanceof |
1892 | 1892 | EE_Attendee |
1893 | 1893 | ) { |
@@ -1898,7 +1898,7 @@ discard block |
||
1898 | 1898 | 'event_espresso' |
1899 | 1899 | ), |
1900 | 1900 | '<br/>', |
1901 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1901 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1902 | 1902 | ), |
1903 | 1903 | __FILE__, |
1904 | 1904 | __FUNCTION__, |
@@ -1907,9 +1907,9 @@ discard block |
||
1907 | 1907 | return false; |
1908 | 1908 | } |
1909 | 1909 | /** @type EE_Registration_Processor $registration_processor */ |
1910 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1910 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1911 | 1911 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1912 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1912 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1913 | 1913 | return true; |
1914 | 1914 | } |
1915 | 1915 | |
@@ -1924,22 +1924,22 @@ discard block |
||
1924 | 1924 | * @throws \EE_Error |
1925 | 1925 | */ |
1926 | 1926 | private function _get_payment_method_for_selected_method_of_payment() { |
1927 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
1927 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
1928 | 1928 | $this->_redirect_because_event_sold_out(); |
1929 | 1929 | return null; |
1930 | 1930 | } |
1931 | 1931 | // get EE_Payment_Method object |
1932 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
1933 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1932 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1933 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1934 | 1934 | } else { |
1935 | 1935 | // load EEM_Payment_Method |
1936 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1936 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1937 | 1937 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1938 | 1938 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1939 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1939 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1940 | 1940 | } |
1941 | 1941 | // verify $payment_method |
1942 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1942 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1943 | 1943 | // not a payment |
1944 | 1944 | EE_Error::add_error( |
1945 | 1945 | sprintf( |
@@ -1948,7 +1948,7 @@ discard block |
||
1948 | 1948 | 'event_espresso' |
1949 | 1949 | ), |
1950 | 1950 | '<br/>', |
1951 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1951 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1952 | 1952 | ), |
1953 | 1953 | __FILE__, |
1954 | 1954 | __FUNCTION__, |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | return null; |
1958 | 1958 | } |
1959 | 1959 | // and verify it has a valid Payment_Method Type object |
1960 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1960 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1961 | 1961 | // not a payment |
1962 | 1962 | EE_Error::add_error( |
1963 | 1963 | sprintf( |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | 'event_espresso' |
1967 | 1967 | ), |
1968 | 1968 | '<br/>', |
1969 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1969 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1970 | 1970 | ), |
1971 | 1971 | __FILE__, |
1972 | 1972 | __FUNCTION__, |
@@ -1987,29 +1987,29 @@ discard block |
||
1987 | 1987 | * @return mixed EE_Payment | boolean |
1988 | 1988 | * @throws \EE_Error |
1989 | 1989 | */ |
1990 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1990 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1991 | 1991 | $payment = null; |
1992 | 1992 | $this->checkout->transaction->save(); |
1993 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1994 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1993 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1994 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1995 | 1995 | return false; |
1996 | 1996 | } |
1997 | 1997 | try { |
1998 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1998 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1999 | 1999 | // generate payment object |
2000 | 2000 | $payment = $payment_processor->process_payment( |
2001 | 2001 | $payment_method, |
2002 | 2002 | $this->checkout->transaction, |
2003 | 2003 | $this->checkout->amount_owing, |
2004 | 2004 | $this->checkout->billing_form, |
2005 | - $this->_get_return_url( $payment_method ), |
|
2005 | + $this->_get_return_url($payment_method), |
|
2006 | 2006 | 'CART', |
2007 | 2007 | $this->checkout->admin_request, |
2008 | 2008 | true, |
2009 | 2009 | $this->reg_step_url() |
2010 | 2010 | ); |
2011 | - } catch ( Exception $e ) { |
|
2012 | - $this->_handle_payment_processor_exception( $e ); |
|
2011 | + } catch (Exception $e) { |
|
2012 | + $this->_handle_payment_processor_exception($e); |
|
2013 | 2013 | } |
2014 | 2014 | return $payment; |
2015 | 2015 | } |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | * @return void |
2025 | 2025 | * @throws \EE_Error |
2026 | 2026 | */ |
2027 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
2027 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
2028 | 2028 | EE_Error::add_error( |
2029 | 2029 | sprintf( |
2030 | 2030 | __( |
@@ -2032,7 +2032,7 @@ discard block |
||
2032 | 2032 | 'event_espresso' |
2033 | 2033 | ), |
2034 | 2034 | '<br/>', |
2035 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
2035 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
2036 | 2036 | $e->getMessage(), |
2037 | 2037 | $e->getFile(), |
2038 | 2038 | $e->getLine() |
@@ -2053,9 +2053,9 @@ discard block |
||
2053 | 2053 | * @return string |
2054 | 2054 | * @throws \EE_Error |
2055 | 2055 | */ |
2056 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
2056 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
2057 | 2057 | $return_url = ''; |
2058 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
2058 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
2059 | 2059 | case EE_PMT_Base::offsite : |
2060 | 2060 | $return_url = add_query_arg( |
2061 | 2061 | array( |
@@ -2084,12 +2084,12 @@ discard block |
||
2084 | 2084 | * @return EE_Payment | FALSE |
2085 | 2085 | * @throws \EE_Error |
2086 | 2086 | */ |
2087 | - private function _validate_payment( $payment = null ) { |
|
2088 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
2087 | + private function _validate_payment($payment = null) { |
|
2088 | + if ($this->checkout->payment_method->is_off_line()) { |
|
2089 | 2089 | return true; |
2090 | 2090 | } |
2091 | 2091 | // verify payment object |
2092 | - if ( ! $payment instanceof EE_Payment ) { |
|
2092 | + if ( ! $payment instanceof EE_Payment) { |
|
2093 | 2093 | // not a payment |
2094 | 2094 | EE_Error::add_error( |
2095 | 2095 | sprintf( |
@@ -2098,7 +2098,7 @@ discard block |
||
2098 | 2098 | 'event_espresso' |
2099 | 2099 | ), |
2100 | 2100 | '<br/>', |
2101 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2101 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2102 | 2102 | ), |
2103 | 2103 | __FILE__, |
2104 | 2104 | __FUNCTION__, |
@@ -2119,27 +2119,27 @@ discard block |
||
2119 | 2119 | * @return bool |
2120 | 2120 | * @throws \EE_Error |
2121 | 2121 | */ |
2122 | - private function _post_payment_processing( $payment = null ) { |
|
2122 | + private function _post_payment_processing($payment = null) { |
|
2123 | 2123 | // Off-Line payment? |
2124 | - if ( $payment === true ) { |
|
2124 | + if ($payment === true) { |
|
2125 | 2125 | //$this->_setup_redirect_for_next_step(); |
2126 | 2126 | return true; |
2127 | 2127 | // On-Site payment? |
2128 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
2129 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
2128 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
2129 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
2130 | 2130 | //$this->_setup_redirect_for_next_step(); |
2131 | 2131 | $this->checkout->continue_reg = false; |
2132 | 2132 | } |
2133 | 2133 | // Off-Site payment? |
2134 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
2134 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
2135 | 2135 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
2136 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
2137 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
2136 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
2137 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
2138 | 2138 | $this->checkout->redirect = true; |
2139 | 2139 | $this->checkout->redirect_form = $payment->redirect_form(); |
2140 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
2140 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
2141 | 2141 | // set JSON response |
2142 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
2142 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
2143 | 2143 | // set cron job for finalizing the TXN |
2144 | 2144 | // in case the user does not return from the off-site gateway |
2145 | 2145 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2147,7 +2147,7 @@ discard block |
||
2147 | 2147 | $this->checkout->transaction->ID() |
2148 | 2148 | ); |
2149 | 2149 | // and lastly, let's bump the payment status to pending |
2150 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
2150 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
2151 | 2151 | $payment->save(); |
2152 | 2152 | } else { |
2153 | 2153 | // not a payment |
@@ -2159,7 +2159,7 @@ discard block |
||
2159 | 2159 | 'event_espresso' |
2160 | 2160 | ), |
2161 | 2161 | '<br/>', |
2162 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2162 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2163 | 2163 | ), |
2164 | 2164 | __FILE__, |
2165 | 2165 | __FUNCTION__, |
@@ -2197,21 +2197,21 @@ discard block |
||
2197 | 2197 | * @return bool |
2198 | 2198 | * @throws \EE_Error |
2199 | 2199 | */ |
2200 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
2200 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
2201 | 2201 | // off-line payment? carry on |
2202 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
2202 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
2203 | 2203 | return true; |
2204 | 2204 | } |
2205 | 2205 | // verify payment validity |
2206 | - if ( $payment instanceof EE_Payment ) { |
|
2207 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
2206 | + if ($payment instanceof EE_Payment) { |
|
2207 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
2208 | 2208 | $msg = $payment->gateway_response(); |
2209 | 2209 | // check results |
2210 | - switch ( $payment->status() ) { |
|
2210 | + switch ($payment->status()) { |
|
2211 | 2211 | // good payment |
2212 | 2212 | case EEM_Payment::status_id_approved : |
2213 | 2213 | EE_Error::add_success( |
2214 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
2214 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
2215 | 2215 | __FILE__, |
2216 | 2216 | __FUNCTION__, |
2217 | 2217 | __LINE__ |
@@ -2220,45 +2220,45 @@ discard block |
||
2220 | 2220 | break; |
2221 | 2221 | // slow payment |
2222 | 2222 | case EEM_Payment::status_id_pending : |
2223 | - if ( empty( $msg ) ) { |
|
2223 | + if (empty($msg)) { |
|
2224 | 2224 | $msg = __( |
2225 | 2225 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2226 | 2226 | 'event_espresso' |
2227 | 2227 | ); |
2228 | 2228 | } |
2229 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2229 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2230 | 2230 | return true; |
2231 | 2231 | break; |
2232 | 2232 | // don't wanna payment |
2233 | 2233 | case EEM_Payment::status_id_cancelled : |
2234 | - if ( empty( $msg ) ) { |
|
2234 | + if (empty($msg)) { |
|
2235 | 2235 | $msg = _n( |
2236 | 2236 | 'Payment cancelled. Please try again.', |
2237 | 2237 | 'Payment cancelled. Please try again or select another method of payment.', |
2238 | - count( $this->checkout->available_payment_methods ), |
|
2238 | + count($this->checkout->available_payment_methods), |
|
2239 | 2239 | 'event_espresso' |
2240 | 2240 | ); |
2241 | 2241 | } |
2242 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2242 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2243 | 2243 | return false; |
2244 | 2244 | break; |
2245 | 2245 | // not enough payment |
2246 | 2246 | case EEM_Payment::status_id_declined : |
2247 | - if ( empty( $msg ) ) { |
|
2247 | + if (empty($msg)) { |
|
2248 | 2248 | $msg = _n( |
2249 | 2249 | 'We\'re sorry but your payment was declined. Please try again.', |
2250 | 2250 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2251 | - count( $this->checkout->available_payment_methods ), |
|
2251 | + count($this->checkout->available_payment_methods), |
|
2252 | 2252 | 'event_espresso' |
2253 | 2253 | ); |
2254 | 2254 | } |
2255 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2255 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2256 | 2256 | return false; |
2257 | 2257 | break; |
2258 | 2258 | // bad payment |
2259 | 2259 | case EEM_Payment::status_id_failed : |
2260 | - if ( ! empty( $msg ) ) { |
|
2261 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2260 | + if ( ! empty($msg)) { |
|
2261 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2262 | 2262 | return false; |
2263 | 2263 | } |
2264 | 2264 | // default to error below |
@@ -2267,7 +2267,7 @@ discard block |
||
2267 | 2267 | } |
2268 | 2268 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2269 | 2269 | // the payment processing is just running slower than the registrant's request |
2270 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2270 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2271 | 2271 | return true; |
2272 | 2272 | } |
2273 | 2273 | EE_Error::add_error( |
@@ -2277,7 +2277,7 @@ discard block |
||
2277 | 2277 | 'event_espresso' |
2278 | 2278 | ), |
2279 | 2279 | '<br/>', |
2280 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2280 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2281 | 2281 | ), |
2282 | 2282 | __FILE__, |
2283 | 2283 | __FUNCTION__, |
@@ -2310,13 +2310,13 @@ discard block |
||
2310 | 2310 | public function process_gateway_response() { |
2311 | 2311 | $payment = null; |
2312 | 2312 | // how have they chosen to pay? |
2313 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2313 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2314 | 2314 | // get EE_Payment_Method object |
2315 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2315 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2316 | 2316 | $this->checkout->continue_reg = false; |
2317 | 2317 | return false; |
2318 | 2318 | } |
2319 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2319 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2320 | 2320 | return false; |
2321 | 2321 | } |
2322 | 2322 | $this->_validate_offsite_return(); |
@@ -2330,23 +2330,23 @@ discard block |
||
2330 | 2330 | // true |
2331 | 2331 | //); |
2332 | 2332 | // verify TXN |
2333 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2333 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2334 | 2334 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2335 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2335 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2336 | 2336 | $this->checkout->continue_reg = false; |
2337 | 2337 | return false; |
2338 | 2338 | } |
2339 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2340 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2341 | - $payment = $this->_validate_payment( $payment ); |
|
2339 | + $payment = $this->_process_off_site_payment($gateway); |
|
2340 | + $payment = $this->_process_cancelled_payments($payment); |
|
2341 | + $payment = $this->_validate_payment($payment); |
|
2342 | 2342 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2343 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2343 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2344 | 2344 | //$this->_setup_redirect_for_next_step(); |
2345 | 2345 | // store that for later |
2346 | 2346 | $this->checkout->payment = $payment; |
2347 | 2347 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2348 | 2348 | // because we will complete this step during the IPN processing then |
2349 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2349 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2350 | 2350 | $this->set_completed(); |
2351 | 2351 | } |
2352 | 2352 | return true; |
@@ -2370,21 +2370,21 @@ discard block |
||
2370 | 2370 | * @throws \EE_Error |
2371 | 2371 | */ |
2372 | 2372 | private function _validate_offsite_return() { |
2373 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2374 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2373 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2374 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2375 | 2375 | // Houston... we might have a problem |
2376 | 2376 | $invalid_TXN = false; |
2377 | 2377 | // first gather some info |
2378 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2378 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2379 | 2379 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2380 | 2380 | ? $valid_TXN->primary_registration() |
2381 | 2381 | : null; |
2382 | 2382 | // let's start by retrieving the cart for this TXN |
2383 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2384 | - if ( $cart instanceof EE_Cart ) { |
|
2383 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2384 | + if ($cart instanceof EE_Cart) { |
|
2385 | 2385 | // verify that the current cart has tickets |
2386 | 2386 | $tickets = $cart->get_tickets(); |
2387 | - if ( empty( $tickets ) ) { |
|
2387 | + if (empty($tickets)) { |
|
2388 | 2388 | $invalid_TXN = true; |
2389 | 2389 | } |
2390 | 2390 | } else { |
@@ -2394,35 +2394,35 @@ discard block |
||
2394 | 2394 | ? $primary_registrant->session_ID() |
2395 | 2395 | : null; |
2396 | 2396 | // validate current Session ID and compare against valid TXN session ID |
2397 | - if ( EE_Session::instance()->id() === null ) { |
|
2397 | + if (EE_Session::instance()->id() === null) { |
|
2398 | 2398 | $invalid_TXN = true; |
2399 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
2399 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
2400 | 2400 | // WARNING !!! |
2401 | 2401 | // this could be PayPal sending back duplicate requests (ya they do that) |
2402 | 2402 | // or it **could** mean someone is simply registering AGAIN after having just done so |
2403 | 2403 | // so now we need to determine if this current TXN looks valid or not |
2404 | 2404 | // has this step even been started ? |
2405 | - if ( $this->checkout->transaction->reg_step_completed( $this->slug() === false ) |
|
2405 | + if ($this->checkout->transaction->reg_step_completed($this->slug() === false) |
|
2406 | 2406 | ) { |
2407 | 2407 | // really? you're half way through this reg step, but you never started it ? |
2408 | 2408 | $invalid_TXN = true; |
2409 | 2409 | } |
2410 | 2410 | } |
2411 | - if ( $invalid_TXN ) { |
|
2411 | + if ($invalid_TXN) { |
|
2412 | 2412 | // is the valid TXN completed ? |
2413 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2413 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2414 | 2414 | // has this step even been started ? |
2415 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
2416 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2415 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
2416 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2417 | 2417 | // so it **looks** like this is a double request from PayPal |
2418 | 2418 | // so let's try to pick up where we left off |
2419 | 2419 | $this->checkout->transaction = $valid_TXN; |
2420 | - $this->checkout->refresh_all_entities( true ); |
|
2420 | + $this->checkout->refresh_all_entities(true); |
|
2421 | 2421 | return; |
2422 | 2422 | } |
2423 | 2423 | } |
2424 | 2424 | // you appear to be lost? |
2425 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2425 | + $this->_redirect_wayward_request($primary_registrant); |
|
2426 | 2426 | } |
2427 | 2427 | } |
2428 | 2428 | } |
@@ -2437,14 +2437,14 @@ discard block |
||
2437 | 2437 | * @return bool |
2438 | 2438 | * @throws \EE_Error |
2439 | 2439 | */ |
2440 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2441 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2440 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2441 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2442 | 2442 | // try redirecting based on the current TXN |
2443 | 2443 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2444 | 2444 | ? $this->checkout->transaction->primary_registration() |
2445 | 2445 | : null; |
2446 | 2446 | } |
2447 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2447 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2448 | 2448 | EE_Error::add_error( |
2449 | 2449 | sprintf( |
2450 | 2450 | __( |
@@ -2452,7 +2452,7 @@ discard block |
||
2452 | 2452 | 'event_espresso' |
2453 | 2453 | ), |
2454 | 2454 | '<br/>', |
2455 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2455 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2456 | 2456 | ), |
2457 | 2457 | __FILE__, |
2458 | 2458 | __FUNCTION__, |
@@ -2483,17 +2483,17 @@ discard block |
||
2483 | 2483 | * @return \EE_Payment |
2484 | 2484 | * @throws \EE_Error |
2485 | 2485 | */ |
2486 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2486 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2487 | 2487 | try { |
2488 | 2488 | $request_data = \EE_Registry::instance()->REQ->params(); |
2489 | 2489 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2490 | 2490 | $this->set_handle_IPN_in_this_request( |
2491 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2491 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2492 | 2492 | ); |
2493 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2493 | + if ($this->handle_IPN_in_this_request()) { |
|
2494 | 2494 | // get payment details and process results |
2495 | 2495 | /** @type EE_Payment_Processor $payment_processor */ |
2496 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2496 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2497 | 2497 | $payment = $payment_processor->process_ipn( |
2498 | 2498 | $request_data, |
2499 | 2499 | $this->checkout->transaction, |
@@ -2506,14 +2506,14 @@ discard block |
||
2506 | 2506 | $payment = $this->checkout->transaction->last_payment(); |
2507 | 2507 | //$payment_source = 'last_payment'; |
2508 | 2508 | } |
2509 | - } catch ( Exception $e ) { |
|
2509 | + } catch (Exception $e) { |
|
2510 | 2510 | // let's just eat the exception and try to move on using any previously set payment info |
2511 | 2511 | $payment = $this->checkout->transaction->last_payment(); |
2512 | 2512 | //$payment_source = 'last_payment after Exception'; |
2513 | 2513 | // but if we STILL don't have a payment object |
2514 | - if ( ! $payment instanceof EE_Payment ) { |
|
2514 | + if ( ! $payment instanceof EE_Payment) { |
|
2515 | 2515 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2516 | - $this->_handle_payment_processor_exception( $e ); |
|
2516 | + $this->_handle_payment_processor_exception($e); |
|
2517 | 2517 | } |
2518 | 2518 | } |
2519 | 2519 | // DEBUG LOG |
@@ -2538,13 +2538,13 @@ discard block |
||
2538 | 2538 | * @return EE_Payment | FALSE |
2539 | 2539 | * @throws \EE_Error |
2540 | 2540 | */ |
2541 | - private function _process_cancelled_payments( $payment = null ) { |
|
2541 | + private function _process_cancelled_payments($payment = null) { |
|
2542 | 2542 | if ( |
2543 | 2543 | $payment instanceof EE_Payment |
2544 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2544 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2545 | 2545 | && $payment->status() === EEM_Payment::status_id_failed |
2546 | 2546 | ) { |
2547 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2547 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2548 | 2548 | } |
2549 | 2549 | return $payment; |
2550 | 2550 | } |
@@ -2561,14 +2561,14 @@ discard block |
||
2561 | 2561 | public function get_transaction_details_for_gateways() { |
2562 | 2562 | $txn_details = array(); |
2563 | 2563 | // ya gotta make a choice man |
2564 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2564 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2565 | 2565 | $txn_details = array( |
2566 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2566 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2567 | 2567 | ); |
2568 | 2568 | } |
2569 | 2569 | // get EE_Payment_Method object |
2570 | 2570 | if ( |
2571 | - empty( $txn_details ) |
|
2571 | + empty($txn_details) |
|
2572 | 2572 | && |
2573 | 2573 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2574 | 2574 | ) { |
@@ -2580,8 +2580,8 @@ discard block |
||
2580 | 2580 | ) |
2581 | 2581 | ); |
2582 | 2582 | } |
2583 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2584 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2583 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2584 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2585 | 2585 | $txn_details = array( |
2586 | 2586 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2587 | 2587 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2592,7 +2592,7 @@ discard block |
||
2592 | 2592 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2593 | 2593 | 'payment_amount' => $this->checkout->amount_owing, |
2594 | 2594 | 'return_url' => $return_url, |
2595 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2595 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2596 | 2596 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2597 | 2597 | array( |
2598 | 2598 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2601,7 +2601,7 @@ discard block |
||
2601 | 2601 | ) |
2602 | 2602 | ); |
2603 | 2603 | } |
2604 | - echo json_encode( $txn_details ); |
|
2604 | + echo json_encode($txn_details); |
|
2605 | 2605 | exit(); |
2606 | 2606 | } |
2607 | 2607 |
@@ -277,17 +277,17 @@ |
||
277 | 277 | //if we know who the attendee is, and this is a billing form |
278 | 278 | //that uses attendee info, populate it |
279 | 279 | if ( |
280 | - apply_filters( |
|
281 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
282 | - ( |
|
283 | - $this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
284 | - && $transaction instanceof EE_Transaction |
|
285 | - && $transaction->primary_registration() instanceof EE_Registration |
|
286 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
287 | - ), |
|
288 | - $this->_billing_form, |
|
289 | - $transaction |
|
290 | - ) |
|
280 | + apply_filters( |
|
281 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
282 | + ( |
|
283 | + $this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
284 | + && $transaction instanceof EE_Transaction |
|
285 | + && $transaction->primary_registration() instanceof EE_Registration |
|
286 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
287 | + ), |
|
288 | + $this->_billing_form, |
|
289 | + $transaction |
|
290 | + ) |
|
291 | 291 | ){ |
292 | 292 | $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
293 | 293 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
186 | 186 | // first use WP locate_template to check for template in the current theme folder |
187 | - $template_path = locate_template( $templates ); |
|
187 | + $template_path = locate_template($templates); |
|
188 | 188 | |
189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
189 | + if ($check_if_custom && ! empty($template_path)) |
|
190 | 190 | return TRUE; |
191 | 191 | |
192 | 192 | // not in the theme |
193 | - if ( empty( $template_path )) { |
|
193 | + if (empty($template_path)) { |
|
194 | 194 | // not even a template to look for ? |
195 | - if ( empty( $templates )) { |
|
195 | + if (empty($templates)) { |
|
196 | 196 | // get post_type |
197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
198 | 198 | // get array of EE Custom Post Types |
199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
200 | 200 | // build template name based on request |
201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
201 | + if (isset($EE_CPTs[$post_type])) { |
|
202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | // currently active EE template theme |
@@ -210,81 +210,81 @@ discard block |
||
210 | 210 | // array of paths to folders that may contain templates |
211 | 211 | $template_folder_paths = array( |
212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
216 | 216 | ); |
217 | 217 | |
218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
219 | - if ( ! $check_if_custom ) { |
|
219 | + if ( ! $check_if_custom) { |
|
220 | 220 | $core_paths = array( |
221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
222 | - EE_PUBLIC . $current_theme, |
|
222 | + EE_PUBLIC.$current_theme, |
|
223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
224 | - EE_TEMPLATES . $current_theme, |
|
224 | + EE_TEMPLATES.$current_theme, |
|
225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
226 | 226 | EE_PLUGIN_DIR_PATH |
227 | 227 | ); |
228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // now filter that array |
232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
235 | 235 | // array to hold all possible template paths |
236 | 236 | $full_template_paths = array(); |
237 | 237 | |
238 | 238 | // loop through $templates |
239 | - foreach ( $templates as $template ) { |
|
239 | + foreach ($templates as $template) { |
|
240 | 240 | // normalize directory separators |
241 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
242 | - $file_name = basename( $template ); |
|
243 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
241 | + $template = EEH_File::standardise_directory_separators($template); |
|
242 | + $file_name = basename($template); |
|
243 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
244 | 244 | // while looping through all template folder paths |
245 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
245 | + foreach ($template_folder_paths as $template_folder_path) { |
|
246 | 246 | // normalize directory separators |
247 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
247 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
248 | 248 | // determine if any common base path exists between the two paths |
249 | 249 | $common_base_path = EEH_Template::_find_common_base_path( |
250 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
250 | + array($template_folder_path, $template_path_minus_file_name) |
|
251 | 251 | ); |
252 | - if ( $common_base_path !== '' ) { |
|
252 | + if ($common_base_path !== '') { |
|
253 | 253 | // both paths have a common base, so just tack the filename onto our search path |
254 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
254 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
255 | 255 | } else { |
256 | 256 | // no common base path, so let's just concatenate |
257 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
257 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
258 | 258 | } |
259 | 259 | // build up our template locations array by adding our resolved paths |
260 | 260 | $full_template_paths[] = $resolved_path; |
261 | 261 | } |
262 | 262 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
263 | - array_unshift( $full_template_paths, $template ); |
|
263 | + array_unshift($full_template_paths, $template); |
|
264 | 264 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
265 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
265 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
266 | 266 | } |
267 | 267 | // filter final array of full template paths |
268 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
268 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
269 | 269 | // now loop through our final array of template location paths and check each location |
270 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
271 | - if ( is_readable( $full_template_path )) { |
|
272 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
270 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
271 | + if (is_readable($full_template_path)) { |
|
272 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
273 | 273 | // hook that can be used to display the full template path that will be used |
274 | - do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path ); |
|
274 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | // if we got it and you want to see it... |
280 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
281 | - if ( $return_string ) { |
|
282 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
280 | + if ($template_path && $load && ! $check_if_custom) { |
|
281 | + if ($return_string) { |
|
282 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
283 | 283 | } else { |
284 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
284 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
285 | 285 | } |
286 | 286 | } |
287 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
287 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | * @param array $paths |
298 | 298 | * @return string |
299 | 299 | */ |
300 | - protected static function _find_common_base_path( $paths ) { |
|
300 | + protected static function _find_common_base_path($paths) { |
|
301 | 301 | $last_offset = 0; |
302 | 302 | $common_base_path = ''; |
303 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
303 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
304 | 304 | $dir_length = $index - $last_offset + 1; |
305 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
306 | - foreach ( $paths as $path ) { |
|
307 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
305 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
306 | + foreach ($paths as $path) { |
|
307 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
308 | 308 | return $common_base_path; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | $common_base_path .= $directory; |
312 | 312 | $last_offset = $index + 1; |
313 | 313 | } |
314 | - return substr( $common_base_path, 0, -1 ); |
|
314 | + return substr($common_base_path, 0, -1); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
324 | 324 | * @return mixed string |
325 | 325 | */ |
326 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
326 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -334,26 +334,26 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @since 4.6.0 |
336 | 336 | */ |
337 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
338 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
337 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
338 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
339 | 339 | |
340 | 340 | // you gimme nuttin - YOU GET NUTTIN !! |
341 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
341 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
342 | 342 | return ''; |
343 | 343 | } |
344 | 344 | // if $template_args are not in an array, then make it so |
345 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
346 | - $template_args = array( $template_args ); |
|
345 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
346 | + $template_args = array($template_args); |
|
347 | 347 | } |
348 | - extract( (array) $template_args); |
|
348 | + extract((array) $template_args); |
|
349 | 349 | |
350 | - if ( $return_string ) { |
|
350 | + if ($return_string) { |
|
351 | 351 | // because we want to return a string, we are going to capture the output |
352 | 352 | ob_start(); |
353 | - include( $template_path ); |
|
353 | + include($template_path); |
|
354 | 354 | return ob_get_clean(); |
355 | 355 | } else { |
356 | - include( $template_path ); |
|
356 | + include($template_path); |
|
357 | 357 | } |
358 | 358 | return ''; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * @param string $suffix added to the end of the generated class |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
374 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
375 | 375 | // in the beginning... |
376 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
376 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
377 | 377 | // da muddle |
378 | 378 | $class = ''; |
379 | 379 | // the end |
380 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
380 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
381 | 381 | // is the passed object an EE object ? |
382 | - if ( $object instanceof EE_Base_Class ) { |
|
382 | + if ($object instanceof EE_Base_Class) { |
|
383 | 383 | // grab the exact type of object |
384 | - $obj_class = get_class( $object ); |
|
384 | + $obj_class = get_class($object); |
|
385 | 385 | // depending on the type of object... |
386 | - switch ( $obj_class ) { |
|
386 | + switch ($obj_class) { |
|
387 | 387 | // no specifics just yet... |
388 | 388 | default : |
389 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
390 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
389 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
390 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | } |
394 | - return $prefix . $class . $suffix; |
|
394 | + return $prefix.$class.$suffix; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -407,54 +407,54 @@ discard block |
||
407 | 407 | * @param string $cur_code_span_class |
408 | 408 | * @return string the html output for the formatted money value |
409 | 409 | */ |
410 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
410 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
411 | 411 | // ensure amount was received |
412 | - if ( is_null( $amount ) ) { |
|
413 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
414 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
412 | + if (is_null($amount)) { |
|
413 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
414 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
415 | 415 | return ''; |
416 | 416 | } |
417 | 417 | //ensure amount is float |
418 | - $amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount ); |
|
419 | - $CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount ); |
|
418 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
419 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
422 | 422 | // still a number or was amount converted to a string like "free" ? |
423 | - if ( is_float( $amount_formatted )) { |
|
423 | + if (is_float($amount_formatted)) { |
|
424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
426 | 426 | // verify results |
427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
428 | 428 | // set default config country currency settings |
429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
430 | 430 | } |
431 | 431 | // format float |
432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
433 | 433 | // add formatting ? |
434 | - if ( ! $return_raw ) { |
|
434 | + if ( ! $return_raw) { |
|
435 | 435 | // add currency sign |
436 | - if( $mny->sign_b4 ){ |
|
437 | - if( $amount >= 0 ){ |
|
438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
439 | - }else{ |
|
440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
436 | + if ($mny->sign_b4) { |
|
437 | + if ($amount >= 0) { |
|
438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
439 | + } else { |
|
440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
441 | 441 | } |
442 | 442 | |
443 | - }else{ |
|
444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
443 | + } else { |
|
444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // filter to allow global setting of display_code |
448 | - $display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code ); |
|
448 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
449 | 449 | |
450 | 450 | // add currency code ? |
451 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
451 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
452 | 452 | } |
453 | 453 | // filter results |
454 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
454 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
455 | 455 | } |
456 | 456 | // clean up vars |
457 | - unset( $mny ); |
|
457 | + unset($mny); |
|
458 | 458 | // return formatted currency amount |
459 | 459 | return $amount_formatted; |
460 | 460 | } |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
470 | 470 | * @return string The localized label for the status id. |
471 | 471 | */ |
472 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
472 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
473 | 473 | /** @type EEM_Status $EEM_Status */ |
474 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
475 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
476 | - return $status[ $status_id ]; |
|
474 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
475 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
476 | + return $status[$status_id]; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -488,21 +488,21 @@ discard block |
||
488 | 488 | * @param string $title |
489 | 489 | * @return string the html output for the button |
490 | 490 | */ |
491 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '', $title = '' ) { |
|
491 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') { |
|
492 | 492 | $icon_html = ''; |
493 | - if ( ! empty( $icon ) ) { |
|
494 | - $dashicons = preg_split( "(ee-icon |dashicons )", $icon ); |
|
495 | - $dashicons = array_filter( $dashicons ); |
|
496 | - $count = count( $dashicons ); |
|
493 | + if ( ! empty($icon)) { |
|
494 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
495 | + $dashicons = array_filter($dashicons); |
|
496 | + $count = count($dashicons); |
|
497 | 497 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
498 | - foreach ( $dashicons as $dashicon ) { |
|
499 | - $type = strpos( $dashicon, 'ee-icon' ) !== false ? 'ee-icon ' : 'dashicons '; |
|
500 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
498 | + foreach ($dashicons as $dashicon) { |
|
499 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
500 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
501 | 501 | } |
502 | 502 | $icon_html .= $count > 1 ? '</span>' : ''; |
503 | 503 | } |
504 | - $label = ! empty( $icon ) ? $icon_html . $label : $label; |
|
505 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
504 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
505 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
506 | 506 | return $button; |
507 | 507 | } |
508 | 508 | |
@@ -519,21 +519,21 @@ discard block |
||
519 | 519 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
520 | 520 | * @return string generated link |
521 | 521 | */ |
522 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
522 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
523 | 523 | |
524 | - if ( ! $page ) |
|
525 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
524 | + if ( ! $page) |
|
525 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
526 | 526 | |
527 | - if ( ! $action ) |
|
528 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
527 | + if ( ! $action) |
|
528 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
529 | 529 | |
530 | 530 | $action = empty($action) ? 'default' : $action; |
531 | 531 | |
532 | 532 | |
533 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
534 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
535 | - $help_text = !$help_text ? '' : $help_text; |
|
536 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
533 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
534 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
535 | + $help_text = ! $help_text ? '' : $help_text; |
|
536 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,31 +545,31 @@ discard block |
||
545 | 545 | * @param EE_Help_Tour |
546 | 546 | * @return string html |
547 | 547 | */ |
548 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
548 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
549 | 549 | $id = $tour->get_slug(); |
550 | 550 | $stops = $tour->get_stops(); |
551 | 551 | |
552 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
552 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
553 | 553 | |
554 | - foreach ( $stops as $stop ) { |
|
555 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
556 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
554 | + foreach ($stops as $stop) { |
|
555 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
556 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
557 | 557 | |
558 | 558 | //if container is set to modal then let's make sure we set the options accordingly |
559 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
559 | + if (empty($data_id) && empty($data_class)) { |
|
560 | 560 | $stop['options']['modal'] = true; |
561 | 561 | $stop['options']['expose'] = true; |
562 | 562 | } |
563 | 563 | |
564 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
565 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
564 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
565 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
566 | 566 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
567 | 567 | |
568 | 568 | //options |
569 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
569 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
570 | 570 | $options = ' data-options="'; |
571 | - foreach ( $stop['options'] as $option => $value ) { |
|
572 | - $options .= $option . ':' . $value . ';'; |
|
571 | + foreach ($stop['options'] as $option => $value) { |
|
572 | + $options .= $option.':'.$value.';'; |
|
573 | 573 | } |
574 | 574 | $options .= '"'; |
575 | 575 | } else { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | //let's put all together |
580 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
580 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | $content .= '</ol>'; |
@@ -598,31 +598,31 @@ discard block |
||
598 | 598 | * @throws EE_Error |
599 | 599 | * @return string html structure for status. |
600 | 600 | */ |
601 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
602 | - if ( !is_array( $status_array ) ) |
|
603 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
601 | + public static function status_legend($status_array, $active_status = '') { |
|
602 | + if ( ! is_array($status_array)) |
|
603 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
604 | 604 | |
605 | 605 | $setup_array = array(); |
606 | - foreach ( $status_array as $item => $status ) { |
|
606 | + foreach ($status_array as $item => $status) { |
|
607 | 607 | $setup_array[$item] = array( |
608 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
609 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
608 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
609 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
610 | 610 | 'status' => $status |
611 | 611 | ); |
612 | 612 | } |
613 | 613 | |
614 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
615 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
616 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
617 | - foreach ( $setup_array as $item => $details ) { |
|
614 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
615 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
616 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
617 | + foreach ($setup_array as $item => $details) { |
|
618 | 618 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
619 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
620 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
621 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
622 | - $content .= '</dt>' . "\n"; |
|
619 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
620 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
621 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
622 | + $content .= '</dt>'."\n"; |
|
623 | 623 | } |
624 | - $content .= '</dl>' . "\n"; |
|
625 | - $content .= '</div>' . "\n"; |
|
624 | + $content .= '</dl>'."\n"; |
|
625 | + $content .= '</div>'."\n"; |
|
626 | 626 | return $content; |
627 | 627 | } |
628 | 628 | |
@@ -635,8 +635,8 @@ discard block |
||
635 | 635 | * @return string |
636 | 636 | */ |
637 | 637 | public static function layout_array_as_table($data) { |
638 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
639 | - $data = (array)$data; |
|
638 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
639 | + $data = (array) $data; |
|
640 | 640 | } |
641 | 641 | ob_start(); |
642 | 642 | if (is_array($data)) { |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | ?> |
650 | 650 | <tr> |
651 | 651 | <td> |
652 | - <?php echo $data_key;?> |
|
652 | + <?php echo $data_key; ?> |
|
653 | 653 | </td> |
654 | 654 | <td> |
655 | - <?php echo self::layout_array_as_table($data_values);?> |
|
655 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
656 | 656 | </td> |
657 | 657 | </tr> |
658 | 658 | <?php |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | <ul> |
667 | 667 | <?php |
668 | 668 | foreach ($data as $datum) { |
669 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
669 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
670 | 670 | }?> |
671 | 671 | </ul> |
672 | 672 | <?php |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
700 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
699 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
700 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | * ) |
722 | 722 | * @return string |
723 | 723 | */ |
724 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
724 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
725 | 725 | $page_links = array(); |
726 | 726 | $disable_first = $disable_last = ''; |
727 | 727 | $total_items = (int) $total_items; |
728 | 728 | $per_page = (int) $per_page; |
729 | 729 | $current = (int) $current; |
730 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
730 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
731 | 731 | |
732 | 732 | //filter items_label |
733 | 733 | $items_label = apply_filters( |
@@ -735,68 +735,68 @@ discard block |
||
735 | 735 | $items_label |
736 | 736 | ); |
737 | 737 | |
738 | - if ( empty( $items_label ) |
|
739 | - || ! is_array( $items_label ) |
|
740 | - || ! isset( $items_label['single'] ) |
|
741 | - || ! isset( $items_label['plural'] ) ) { |
|
738 | + if (empty($items_label) |
|
739 | + || ! is_array($items_label) |
|
740 | + || ! isset($items_label['single']) |
|
741 | + || ! isset($items_label['plural'])) { |
|
742 | 742 | $items_label = array( |
743 | - 'single' => __( '1 item', 'event_espresso' ), |
|
744 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
743 | + 'single' => __('1 item', 'event_espresso'), |
|
744 | + 'plural' => __('%s items', 'event_espresso') |
|
745 | 745 | ); |
746 | 746 | } else { |
747 | 747 | $items_label = array( |
748 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
749 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
748 | + 'single' => '1 '.esc_html($items_label['single']), |
|
749 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
750 | 750 | ); |
751 | 751 | } |
752 | 752 | |
753 | - $total_pages = ceil( $total_items / $per_page ); |
|
753 | + $total_pages = ceil($total_items / $per_page); |
|
754 | 754 | |
755 | - if ( $total_pages <= 1 ) |
|
755 | + if ($total_pages <= 1) |
|
756 | 756 | return ''; |
757 | 757 | |
758 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
758 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
759 | 759 | |
760 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
760 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
761 | 761 | |
762 | - if ( $current === 1 ) { |
|
762 | + if ($current === 1) { |
|
763 | 763 | $disable_first = ' disabled'; |
764 | 764 | } |
765 | - if ( $current == $total_pages ) { |
|
765 | + if ($current == $total_pages) { |
|
766 | 766 | $disable_last = ' disabled'; |
767 | 767 | } |
768 | 768 | |
769 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
770 | - 'first-page' . $disable_first, |
|
771 | - esc_attr__( 'Go to the first page' ), |
|
772 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
769 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
770 | + 'first-page'.$disable_first, |
|
771 | + esc_attr__('Go to the first page'), |
|
772 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
773 | 773 | '«' |
774 | 774 | ); |
775 | 775 | |
776 | 776 | $page_links[] = sprintf( |
777 | 777 | '<a class="%s" title="%s" href="%s">%s</a>', |
778 | - 'prev-page' . $disable_first, |
|
779 | - esc_attr__( 'Go to the previous page' ), |
|
780 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
778 | + 'prev-page'.$disable_first, |
|
779 | + esc_attr__('Go to the previous page'), |
|
780 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
781 | 781 | '‹' |
782 | 782 | ); |
783 | 783 | |
784 | - if ( ! $show_num_field ) { |
|
784 | + if ( ! $show_num_field) { |
|
785 | 785 | $html_current_page = $current; |
786 | 786 | } else { |
787 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
788 | - esc_attr__( 'Current page' ), |
|
787 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
788 | + esc_attr__('Current page'), |
|
789 | 789 | $current, |
790 | - strlen( $total_pages ) |
|
790 | + strlen($total_pages) |
|
791 | 791 | ); |
792 | 792 | } |
793 | 793 | |
794 | 794 | $html_total_pages = sprintf( |
795 | 795 | '<span class="total-pages">%s</span>', |
796 | - number_format_i18n( $total_pages ) |
|
796 | + number_format_i18n($total_pages) |
|
797 | 797 | ); |
798 | 798 | $page_links[] = sprintf( |
799 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
799 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
800 | 800 | $html_current_page, |
801 | 801 | $html_total_pages, |
802 | 802 | '<span class="paging-input">', |
@@ -805,29 +805,29 @@ discard block |
||
805 | 805 | |
806 | 806 | $page_links[] = sprintf( |
807 | 807 | '<a class="%s" title="%s" href="%s">%s</a>', |
808 | - 'next-page' . $disable_last, |
|
809 | - esc_attr__( 'Go to the next page' ), |
|
810 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
808 | + 'next-page'.$disable_last, |
|
809 | + esc_attr__('Go to the next page'), |
|
810 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
811 | 811 | '›' |
812 | 812 | ); |
813 | 813 | |
814 | 814 | $page_links[] = sprintf( |
815 | 815 | '<a class="%s" title="%s" href="%s">%s</a>', |
816 | - 'last-page' . $disable_last, |
|
817 | - esc_attr__( 'Go to the last page' ), |
|
818 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
816 | + 'last-page'.$disable_last, |
|
817 | + esc_attr__('Go to the last page'), |
|
818 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
819 | 819 | '»' |
820 | 820 | ); |
821 | 821 | |
822 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
822 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
823 | 823 | // set page class |
824 | - if ( $total_pages ) { |
|
824 | + if ($total_pages) { |
|
825 | 825 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
826 | 826 | } else { |
827 | 827 | $page_class = ' no-pages'; |
828 | 828 | } |
829 | 829 | |
830 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
830 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * @param string $wrap_id |
838 | 838 | * @return string |
839 | 839 | */ |
840 | - public static function powered_by_event_espresso( $wrap_class = '', $wrap_id = '' ) { |
|
841 | - $admin = is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
840 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '') { |
|
841 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
842 | 842 | if ( |
843 | 843 | ! $admin && |
844 | 844 | ! apply_filters( |
@@ -849,17 +849,17 @@ discard block |
||
849 | 849 | return ''; |
850 | 850 | } |
851 | 851 | $tag = $admin ? 'span' : 'div'; |
852 | - $attributes = ! empty( $wrap_id ) ? " id=\"{$wrap_id}\"" : ''; |
|
852 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
853 | 853 | $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
854 | - $attributes .= ! empty( $wrap_class ) |
|
854 | + $attributes .= ! empty($wrap_class) |
|
855 | 855 | ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
856 | 856 | : ' class="powered-by-event-espresso-credit"'; |
857 | - $powered_by = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso_text', $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso' ); |
|
857 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
858 | 858 | $url = add_query_arg( |
859 | - array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id() ), |
|
859 | + array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id()), |
|
860 | 860 | 'https://eventespresso.com/' |
861 | 861 | ); |
862 | - $url = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso__url', $url ); |
|
862 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
863 | 863 | return (string) apply_filters( |
864 | 864 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
865 | 865 | sprintf( |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
892 | 892 | |
893 | 893 | |
894 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
894 | +if ( ! function_exists('espresso_pagination')) { |
|
895 | 895 | /** |
896 | 896 | * espresso_pagination |
897 | 897 | * |
@@ -903,21 +903,21 @@ discard block |
||
903 | 903 | $big = 999999999; // need an unlikely integer |
904 | 904 | $pagination = paginate_links( |
905 | 905 | array( |
906 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
906 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
907 | 907 | 'format' => '?paged=%#%', |
908 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
908 | + 'current' => max(1, get_query_var('paged')), |
|
909 | 909 | 'total' => $wp_query->max_num_pages, |
910 | 910 | 'show_all' => true, |
911 | 911 | 'end_size' => 10, |
912 | 912 | 'mid_size' => 6, |
913 | 913 | 'prev_next' => true, |
914 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
915 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
914 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
915 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
916 | 916 | 'type' => 'plain', |
917 | 917 | 'add_args' => false, |
918 | 918 | 'add_fragment' => '' |
919 | 919 | ) |
920 | 920 | ); |
921 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
921 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
922 | 922 | } |
923 | 923 | } |
924 | 924 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | */ |
44 | 44 | |
45 | -if ( function_exists( 'espresso_version' ) ) { |
|
45 | +if (function_exists('espresso_version')) { |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * espresso_duplicate_plugin_error |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function espresso_duplicate_plugin_error() { |
52 | 52 | ?> |
53 | 53 | <div class="error"> |
54 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
54 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
55 | 55 | </div> |
56 | 56 | <?php |
57 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
57 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
58 | 58 | } |
59 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
59 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
@@ -67,102 +67,102 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | */ |
69 | 69 | function espresso_version() { |
70 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.17.rc.005' ); |
|
70 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.17.rc.005'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // define versions |
74 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
75 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
76 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
77 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
78 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
79 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
74 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
75 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
76 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
77 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
78 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
79 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
80 | 80 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
81 | - if ( ! defined( 'DS' ) ) { |
|
82 | - define( 'DS', '/' ); |
|
81 | + if ( ! defined('DS')) { |
|
82 | + define('DS', '/'); |
|
83 | 83 | } |
84 | - if ( ! defined( 'PS' ) ) { |
|
85 | - define( 'PS', PATH_SEPARATOR ); |
|
84 | + if ( ! defined('PS')) { |
|
85 | + define('PS', PATH_SEPARATOR); |
|
86 | 86 | } |
87 | - if ( ! defined( 'SP' ) ) { |
|
88 | - define( 'SP', ' ' ); |
|
87 | + if ( ! defined('SP')) { |
|
88 | + define('SP', ' '); |
|
89 | 89 | } |
90 | - if ( ! defined( 'EENL' ) ) { |
|
91 | - define( 'EENL', "\n" ); |
|
90 | + if ( ! defined('EENL')) { |
|
91 | + define('EENL', "\n"); |
|
92 | 92 | } |
93 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
93 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
94 | 94 | // define the plugin directory and URL |
95 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
95 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
96 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | 98 | // main root folder paths |
99 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
100 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
101 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
102 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
103 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
104 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
105 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
106 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
99 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
100 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
101 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
102 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
103 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
104 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
105 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
106 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
107 | 107 | // core system paths |
108 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
109 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
110 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
111 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
112 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
113 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
114 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
115 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
116 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
117 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
118 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
119 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
108 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
109 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
110 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
111 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
112 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
113 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
114 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
115 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
116 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
117 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
118 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
119 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
120 | 120 | // gateways |
121 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
122 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
121 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
122 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
123 | 123 | // asset URL paths |
124 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
125 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
126 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
127 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
128 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
129 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
124 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
125 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
126 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
127 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
128 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
129 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
130 | 130 | // define upload paths |
131 | 131 | $uploads = wp_upload_dir(); |
132 | 132 | // define the uploads directory and URL |
133 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
134 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
133 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
135 | 135 | // define the templates directory and URL |
136 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
136 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
138 | 138 | // define the gateway directory and URL |
139 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
139 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | 141 | // languages folder/path |
142 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
143 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
142 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
143 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
144 | 144 | //check for dompdf fonts in uploads |
145 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
146 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
145 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
146 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
147 | 147 | } |
148 | 148 | //ajax constants |
149 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
150 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
149 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
150 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
151 | 151 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
152 | 152 | //you're better to use this than its straight value (currently -1) in case you ever |
153 | 153 | //want to change its default value! or find when -1 means infinity |
154 | - define( 'EE_INF_IN_DB', -1 ); |
|
155 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
156 | - define( 'EE_DEBUG', false ); |
|
154 | + define('EE_INF_IN_DB', -1); |
|
155 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
156 | + define('EE_DEBUG', false); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * espresso_plugin_activation |
160 | 160 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
161 | 161 | */ |
162 | 162 | function espresso_plugin_activation() { |
163 | - update_option( 'ee_espresso_activation', true ); |
|
163 | + update_option('ee_espresso_activation', true); |
|
164 | 164 | } |
165 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
165 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | // } |
177 | 177 | // |
178 | 178 | } |
179 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
179 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function espresso_load_error_handling() { |
188 | 188 | // load debugging tools |
189 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
190 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
189 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
190 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
191 | 191 | EEH_Debug_Tools::instance(); |
192 | 192 | } |
193 | 193 | // load error handling |
194 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
195 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
194 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
195 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
196 | 196 | } else { |
197 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
197 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @param string $full_path_to_file |
209 | 209 | * @throws EE_Error |
210 | 210 | */ |
211 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
211 | + function espresso_load_required($classname, $full_path_to_file) { |
|
212 | 212 | static $error_handling_loaded = false; |
213 | - if ( ! $error_handling_loaded ) { |
|
213 | + if ( ! $error_handling_loaded) { |
|
214 | 214 | espresso_load_error_handling(); |
215 | 215 | $error_handling_loaded = true; |
216 | 216 | } |
217 | - if ( is_readable( $full_path_to_file ) ) { |
|
218 | - require_once( $full_path_to_file ); |
|
217 | + if (is_readable($full_path_to_file)) { |
|
218 | + require_once($full_path_to_file); |
|
219 | 219 | } else { |
220 | - throw new EE_Error ( sprintf( |
|
221 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
220 | + throw new EE_Error(sprintf( |
|
221 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
222 | 222 | $classname |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
228 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
229 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
227 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
228 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
229 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
230 | 230 | new EE_Bootstrap(); |
231 | 231 | |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | |
237 | 237 | |
238 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
238 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
239 | 239 | /** |
240 | 240 | * deactivate_plugin |
241 | 241 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
248 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
249 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
247 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
248 | + if ( ! function_exists('deactivate_plugins')) { |
|
249 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
250 | 250 | } |
251 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
252 | - deactivate_plugins( $plugin_basename ); |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | 253 | } |
254 | 254 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param \EE_Message_Resource_Manager $Message_Resource_Manager |
54 | 54 | * @return \EE_Message_Factory instance |
55 | 55 | */ |
56 | - public static function instance( EE_Message_Resource_Manager $Message_Resource_Manager ) { |
|
56 | + public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager) { |
|
57 | 57 | // check if class object is instantiated, and instantiated properly |
58 | - if ( ! self::$_instance instanceof EE_Message_Factory ) { |
|
59 | - self::$_instance = new EE_Message_Factory( $Message_Resource_Manager ); |
|
58 | + if ( ! self::$_instance instanceof EE_Message_Factory) { |
|
59 | + self::$_instance = new EE_Message_Factory($Message_Resource_Manager); |
|
60 | 60 | } |
61 | 61 | return self::$_instance; |
62 | 62 | } |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * @param array $props_n_values |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public static function create( $props_n_values = array() ) { |
|
71 | + public static function create($props_n_values = array()) { |
|
72 | 72 | /** @type EE_Message_Factory $Message_Factory */ |
73 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
74 | - return $Message_Factory->_create( $props_n_values ); |
|
73 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
74 | + return $Message_Factory->_create($props_n_values); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @return \EE_Message |
83 | 83 | * @throws \EE_Error |
84 | 84 | */ |
85 | - public static function set_messenger_and_message_type( EE_Message $message ) { |
|
85 | + public static function set_messenger_and_message_type(EE_Message $message) { |
|
86 | 86 | /** @type EE_Message_Factory $Message_Factory */ |
87 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
88 | - return $Message_Factory->_set_messenger_and_message_type( $message ); |
|
87 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
88 | + return $Message_Factory->_set_messenger_and_message_type($message); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @return \EE_Message |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public static function set_messenger( EE_Message $message ) { |
|
99 | + public static function set_messenger(EE_Message $message) { |
|
100 | 100 | /** @type EE_Message_Factory $Message_Factory */ |
101 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
102 | - return $Message_Factory->_set_messenger( $message ); |
|
101 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
102 | + return $Message_Factory->_set_messenger($message); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * @return \EE_Message |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public static function set_message_type( EE_Message $message ) { |
|
113 | + public static function set_message_type(EE_Message $message) { |
|
114 | 114 | /** @type EE_Message_Factory $Message_Factory */ |
115 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
116 | - return $Message_Factory->_set_message_type( $message ); |
|
115 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
116 | + return $Message_Factory->_set_message_type($message); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * @return \EE_Message |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - protected function _create( $props_n_values = array() ) { |
|
127 | + protected function _create($props_n_values = array()) { |
|
128 | 128 | return $this->_set_messenger_and_message_type( |
129 | - EE_Message::new_instance( $props_n_values ), |
|
130 | - empty( $props_n_values['MSG_ID'] ) |
|
129 | + EE_Message::new_instance($props_n_values), |
|
130 | + empty($props_n_values['MSG_ID']) |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * @return \EE_Message |
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | - protected function _set_messenger_and_message_type( EE_Message $message, $new_instance = false ) { |
|
144 | - $message = $this->_set_messenger( $message ); |
|
145 | - $message = $this->_set_message_type( $message, $new_instance ); |
|
143 | + protected function _set_messenger_and_message_type(EE_Message $message, $new_instance = false) { |
|
144 | + $message = $this->_set_messenger($message); |
|
145 | + $message = $this->_set_message_type($message, $new_instance); |
|
146 | 146 | return $message; |
147 | 147 | } |
148 | 148 | |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | * @return \EE_Message |
155 | 155 | * @throws \EE_Error |
156 | 156 | */ |
157 | - protected function _set_messenger( EE_Message $message ) { |
|
158 | - $messenger = $this->_message_resource_manager->get_messenger( $message->messenger() ); |
|
159 | - if ( $messenger instanceof EE_messenger ) { |
|
160 | - $message->set_messenger_object( $messenger ); |
|
157 | + protected function _set_messenger(EE_Message $message) { |
|
158 | + $messenger = $this->_message_resource_manager->get_messenger($message->messenger()); |
|
159 | + if ($messenger instanceof EE_messenger) { |
|
160 | + $message->set_messenger_object($messenger); |
|
161 | 161 | } |
162 | 162 | return $message; |
163 | 163 | } |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | * @return \EE_Message |
172 | 172 | * @throws \EE_Error |
173 | 173 | */ |
174 | - protected function _set_message_type( EE_Message $message, $new_instance = false ) { |
|
175 | - $message_type = $this->_message_resource_manager->get_message_type( $message->message_type() ); |
|
176 | - if ( $message_type instanceof EE_message_type ) { |
|
177 | - $message->set_message_type_object( $message_type, $new_instance ); |
|
174 | + protected function _set_message_type(EE_Message $message, $new_instance = false) { |
|
175 | + $message_type = $this->_message_resource_manager->get_message_type($message->message_type()); |
|
176 | + if ($message_type instanceof EE_message_type) { |
|
177 | + $message->set_message_type_object($message_type, $new_instance); |
|
178 | 178 | } |
179 | 179 | return $message; |
180 | 180 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | * @param bool $bydb |
48 | 48 | * @param string $timezone |
49 | 49 | */ |
50 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ) { |
|
51 | - parent::__construct( $fieldValues, $bydb, $timezone ); |
|
52 | - if ( ! $this->get( 'LIN_code' ) ) { |
|
53 | - $this->set_code( $this->generate_code() ); |
|
50 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') { |
|
51 | + parent::__construct($fieldValues, $bydb, $timezone); |
|
52 | + if ( ! $this->get('LIN_code')) { |
|
53 | + $this->set_code($this->generate_code()); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return int |
62 | 62 | */ |
63 | 63 | public function ID() { |
64 | - return $this->get( 'LIN_ID' ); |
|
64 | + return $this->get('LIN_ID'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return int |
72 | 72 | */ |
73 | 73 | public function TXN_ID() { |
74 | - return $this->get( 'TXN_ID' ); |
|
74 | + return $this->get('TXN_ID'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * Sets TXN_ID |
81 | 81 | * @param int $TXN_ID |
82 | 82 | */ |
83 | - public function set_TXN_ID( $TXN_ID ) { |
|
84 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
83 | + public function set_TXN_ID($TXN_ID) { |
|
84 | + $this->set('TXN_ID', $TXN_ID); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @return string |
92 | 92 | */ |
93 | 93 | public function name() { |
94 | - $name = $this->get( 'LIN_name' ); |
|
95 | - if( ! $name ){ |
|
96 | - $name = ucwords( str_replace( '-', ' ', $this->type() ) ); |
|
94 | + $name = $this->get('LIN_name'); |
|
95 | + if ( ! $name) { |
|
96 | + $name = ucwords(str_replace('-', ' ', $this->type())); |
|
97 | 97 | } |
98 | 98 | return $name; |
99 | 99 | } |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * Sets name |
105 | 105 | * @param string $name |
106 | 106 | */ |
107 | - public function set_name( $name ) { |
|
108 | - $this->set( 'LIN_name', $name ); |
|
107 | + public function set_name($name) { |
|
108 | + $this->set('LIN_name', $name); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return string |
116 | 116 | */ |
117 | 117 | public function desc() { |
118 | - return $this->get( 'LIN_desc' ); |
|
118 | + return $this->get('LIN_desc'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * Sets desc |
125 | 125 | * @param string $desc |
126 | 126 | */ |
127 | - public function set_desc( $desc ) { |
|
128 | - $this->set( 'LIN_desc', $desc ); |
|
127 | + public function set_desc($desc) { |
|
128 | + $this->set('LIN_desc', $desc); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return int |
136 | 136 | */ |
137 | 137 | public function quantity() { |
138 | - return $this->get( 'LIN_quantity' ); |
|
138 | + return $this->get('LIN_quantity'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * Sets quantity |
145 | 145 | * @param int $quantity |
146 | 146 | */ |
147 | - function set_quantity( $quantity ) { |
|
148 | - $this->set( 'LIN_quantity', max( $quantity, 0 ) ); |
|
147 | + function set_quantity($quantity) { |
|
148 | + $this->set('LIN_quantity', max($quantity, 0)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return string |
156 | 156 | */ |
157 | 157 | public function OBJ_ID() { |
158 | - return $this->get( 'OBJ_ID' ); |
|
158 | + return $this->get('OBJ_ID'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * Sets item_id |
165 | 165 | * @param string $item_id |
166 | 166 | */ |
167 | - public function set_OBJ_ID( $item_id ) { |
|
168 | - $this->set( 'OBJ_ID', $item_id ); |
|
167 | + public function set_OBJ_ID($item_id) { |
|
168 | + $this->set('OBJ_ID', $item_id); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @return string |
176 | 176 | */ |
177 | 177 | public function OBJ_type() { |
178 | - return $this->get( 'OBJ_type' ); |
|
178 | + return $this->get('OBJ_type'); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * Sets item_type |
213 | 213 | * @param string $OBJ_type |
214 | 214 | */ |
215 | - public function set_OBJ_type( $OBJ_type ) { |
|
216 | - $this->set( 'OBJ_type', $OBJ_type ); |
|
215 | + public function set_OBJ_type($OBJ_type) { |
|
216 | + $this->set('OBJ_type', $OBJ_type); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @return float |
224 | 224 | */ |
225 | 225 | public function unit_price() { |
226 | - return $this->get( 'LIN_unit_price' ); |
|
226 | + return $this->get('LIN_unit_price'); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param float $unit_price |
235 | 235 | */ |
236 | - public function set_unit_price( $unit_price ) { |
|
237 | - $this->set( 'LIN_unit_price', $unit_price ); |
|
236 | + public function set_unit_price($unit_price) { |
|
237 | + $this->set('LIN_unit_price', $unit_price); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | * @return boolean |
246 | 246 | */ |
247 | 247 | public function is_percent() { |
248 | - if( $this->is_tax_sub_total() ) { |
|
248 | + if ($this->is_tax_sub_total()) { |
|
249 | 249 | //tax subtotals HAVE a percent on them, that percentage only applies |
250 | 250 | //to taxable items, so its' an exception. Treat it like a flat line item |
251 | 251 | return false; |
252 | 252 | } |
253 | - $unit_price = abs( $this->get( 'LIN_unit_price' ) ); |
|
254 | - $percent = abs( $this->get( 'LIN_percent' ) ); |
|
255 | - if ( $unit_price < .001 && $percent ) { |
|
253 | + $unit_price = abs($this->get('LIN_unit_price')); |
|
254 | + $percent = abs($this->get('LIN_percent')); |
|
255 | + if ($unit_price < .001 && $percent) { |
|
256 | 256 | return TRUE; |
257 | - } elseif ( $unit_price >= .001 && !$percent ) { |
|
257 | + } elseif ($unit_price >= .001 && ! $percent) { |
|
258 | 258 | return FALSE; |
259 | - } elseif ( $unit_price >= .001 && $percent ) { |
|
260 | - throw new EE_Error( sprintf( __( "A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso" ), $unit_price, $percent ) ); |
|
259 | + } elseif ($unit_price >= .001 && $percent) { |
|
260 | + throw new EE_Error(sprintf(__("A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso"), $unit_price, $percent)); |
|
261 | 261 | } else { |
262 | 262 | // if they're both 0, assume its not a percent item |
263 | 263 | return FALSE; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @return float |
272 | 272 | */ |
273 | 273 | public function percent() { |
274 | - return $this->get( 'LIN_percent' ); |
|
274 | + return $this->get('LIN_percent'); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | * Sets percent (between 100-0.01) |
281 | 281 | * @param float $percent |
282 | 282 | */ |
283 | - public function set_percent( $percent ) { |
|
284 | - $this->set( 'LIN_percent', $percent ); |
|
283 | + public function set_percent($percent) { |
|
284 | + $this->set('LIN_percent', $percent); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return float |
292 | 292 | */ |
293 | 293 | public function total() { |
294 | - return $this->get( 'LIN_total' ); |
|
294 | + return $this->get('LIN_total'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * Sets total |
301 | 301 | * @param float $total |
302 | 302 | */ |
303 | - public function set_total( $total ) { |
|
304 | - $this->set( 'LIN_total', $total ); |
|
303 | + public function set_total($total) { |
|
304 | + $this->set('LIN_total', $total); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return int |
312 | 312 | */ |
313 | 313 | public function order() { |
314 | - return $this->get( 'LIN_order' ); |
|
314 | + return $this->get('LIN_order'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | * Sets order |
321 | 321 | * @param int $order |
322 | 322 | */ |
323 | - public function set_order( $order ) { |
|
324 | - $this->set( 'LIN_order', $order ); |
|
323 | + public function set_order($order) { |
|
324 | + $this->set('LIN_order', $order); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @return int |
332 | 332 | */ |
333 | 333 | public function parent_ID() { |
334 | - return $this->get( 'LIN_parent' ); |
|
334 | + return $this->get('LIN_parent'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * Sets parent |
341 | 341 | * @param int $parent |
342 | 342 | */ |
343 | - public function set_parent_ID( $parent ) { |
|
344 | - $this->set( 'LIN_parent', $parent ); |
|
343 | + public function set_parent_ID($parent) { |
|
344 | + $this->set('LIN_parent', $parent); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @return string |
352 | 352 | */ |
353 | 353 | public function type() { |
354 | - return $this->get( 'LIN_type' ); |
|
354 | + return $this->get('LIN_type'); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | * Sets type |
361 | 361 | * @param string $type |
362 | 362 | */ |
363 | - public function set_type( $type ) { |
|
364 | - $this->set( 'LIN_type', $type ); |
|
363 | + public function set_type($type) { |
|
364 | + $this->set('LIN_type', $type); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | * @return EE_Line_Item |
375 | 375 | */ |
376 | 376 | public function parent() { |
377 | - if( $this->ID() ) { |
|
378 | - return $this->get_model()->get_one_by_ID( $this->parent_ID() ); |
|
377 | + if ($this->ID()) { |
|
378 | + return $this->get_model()->get_one_by_ID($this->parent_ID()); |
|
379 | 379 | } else { |
380 | 380 | return $this->_parent; |
381 | 381 | } |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | * @return EE_Line_Item[] |
389 | 389 | */ |
390 | 390 | public function children() { |
391 | - if ( $this->ID() ) { |
|
391 | + if ($this->ID()) { |
|
392 | 392 | return $this->get_model()->get_all( |
393 | 393 | array( |
394 | - array( 'LIN_parent' => $this->ID() ), |
|
395 | - 'order_by' => array( 'LIN_order' => 'ASC' ) ) ); |
|
394 | + array('LIN_parent' => $this->ID()), |
|
395 | + 'order_by' => array('LIN_order' => 'ASC') ) ); |
|
396 | 396 | } else { |
397 | - if ( ! is_array( $this->_children ) ) { |
|
397 | + if ( ! is_array($this->_children)) { |
|
398 | 398 | $this->_children = array(); |
399 | 399 | } |
400 | 400 | return $this->_children; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return string |
409 | 409 | */ |
410 | 410 | public function code() { |
411 | - return $this->get( 'LIN_code' ); |
|
411 | + return $this->get('LIN_code'); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * Sets code |
418 | 418 | * @param string $code |
419 | 419 | */ |
420 | - public function set_code( $code ) { |
|
421 | - $this->set( 'LIN_code', $code ); |
|
420 | + public function set_code($code) { |
|
421 | + $this->set('LIN_code', $code); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return boolean |
429 | 429 | */ |
430 | 430 | public function is_taxable() { |
431 | - return $this->get( 'LIN_is_taxable' ); |
|
431 | + return $this->get('LIN_is_taxable'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * Sets is_taxable |
438 | 438 | * @param boolean $is_taxable |
439 | 439 | */ |
440 | - public function set_is_taxable( $is_taxable ) { |
|
441 | - $this->set( 'LIN_is_taxable', $is_taxable ); |
|
440 | + public function set_is_taxable($is_taxable) { |
|
441 | + $this->set('LIN_is_taxable', $is_taxable); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public function get_object() { |
455 | 455 | $model_name_of_related_obj = $this->OBJ_type(); |
456 | - return $this->get_model()->has_relation( $model_name_of_related_obj ) ? $this->get_first_related( $model_name_of_related_obj ) : NULL; |
|
456 | + return $this->get_model()->has_relation($model_name_of_related_obj) ? $this->get_first_related($model_name_of_related_obj) : NULL; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | * @param array $query_params |
465 | 465 | * @return EE_Ticket |
466 | 466 | */ |
467 | - public function ticket( $query_params = array() ) { |
|
467 | + public function ticket($query_params = array()) { |
|
468 | 468 | //we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived. This can be overridden via the incoming $query_params argument |
469 | - $remove_defaults = array( 'default_where_conditions' => 'none' ); |
|
470 | - $query_params = array_merge( $remove_defaults, $query_params ); |
|
471 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
469 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
470 | + $query_params = array_merge($remove_defaults, $query_params); |
|
471 | + return $this->get_first_related('Ticket', $query_params); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | |
@@ -478,11 +478,11 @@ discard block |
||
478 | 478 | * @return EE_Datetime | NULL |
479 | 479 | */ |
480 | 480 | public function get_ticket_datetime() { |
481 | - if ( $this->OBJ_type() === 'Ticket' ) { |
|
481 | + if ($this->OBJ_type() === 'Ticket') { |
|
482 | 482 | $ticket = $this->ticket(); |
483 | - if ( $ticket instanceof EE_Ticket ) { |
|
483 | + if ($ticket instanceof EE_Ticket) { |
|
484 | 484 | $datetime = $ticket->first_datetime(); |
485 | - if ( $datetime instanceof EE_Datetime ) { |
|
485 | + if ($datetime instanceof EE_Datetime) { |
|
486 | 486 | return $datetime; |
487 | 487 | } |
488 | 488 | } |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * @return string |
499 | 499 | */ |
500 | 500 | public function ticket_event_name() { |
501 | - $event_name = __( "Unknown", "event_espresso" ); |
|
501 | + $event_name = __("Unknown", "event_espresso"); |
|
502 | 502 | $event = $this->ticket_event(); |
503 | - if ( $event instanceof EE_Event ) { |
|
503 | + if ($event instanceof EE_Event) { |
|
504 | 504 | $event_name = $event->name(); |
505 | 505 | } |
506 | 506 | return $event_name; |
@@ -514,9 +514,9 @@ discard block |
||
514 | 514 | public function ticket_event() { |
515 | 515 | $event = null; |
516 | 516 | $ticket = $this->ticket(); |
517 | - if ( $ticket instanceof EE_Ticket ) { |
|
517 | + if ($ticket instanceof EE_Ticket) { |
|
518 | 518 | $datetime = $ticket->first_datetime(); |
519 | - if ( $datetime instanceof EE_Datetime ) { |
|
519 | + if ($datetime instanceof EE_Datetime) { |
|
520 | 520 | $event = $datetime->event(); |
521 | 521 | } |
522 | 522 | } |
@@ -531,11 +531,11 @@ discard block |
||
531 | 531 | * @param string $time_format |
532 | 532 | * @return string |
533 | 533 | */ |
534 | - public function ticket_datetime_start( $date_format = '', $time_format = '' ) { |
|
535 | - $first_datetime_string = __( "Unknown", "event_espresso" ); |
|
534 | + public function ticket_datetime_start($date_format = '', $time_format = '') { |
|
535 | + $first_datetime_string = __("Unknown", "event_espresso"); |
|
536 | 536 | $datetime = $this->get_ticket_datetime(); |
537 | - if ( $datetime ) { |
|
538 | - $first_datetime_string = $datetime->start_date_and_time( $date_format, $time_format ); |
|
537 | + if ($datetime) { |
|
538 | + $first_datetime_string = $datetime->start_date_and_time($date_format, $time_format); |
|
539 | 539 | } |
540 | 540 | return $first_datetime_string; |
541 | 541 | } |
@@ -550,26 +550,26 @@ discard block |
||
550 | 550 | * @return bool success |
551 | 551 | * @throws \EE_Error |
552 | 552 | */ |
553 | - public function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ) { |
|
553 | + public function add_child_line_item(EEI_Line_Item $line_item, $set_order = true) { |
|
554 | 554 | // should we calculate the LIN_order for this line item ? |
555 | - if ( $set_order || $line_item->order() === null ) { |
|
556 | - $line_item->set_order( count( $this->children() ) ); |
|
555 | + if ($set_order || $line_item->order() === null) { |
|
556 | + $line_item->set_order(count($this->children())); |
|
557 | 557 | } |
558 | - if ( $this->ID() ) { |
|
558 | + if ($this->ID()) { |
|
559 | 559 | //check for any duplicate line items (with the same code), if so, this replaces it |
560 | - $line_item_with_same_code = $this->get_child_line_item( $line_item->code() ); |
|
561 | - if( $line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item ) { |
|
562 | - $this->delete_child_line_item( $line_item_with_same_code->code() ); |
|
560 | + $line_item_with_same_code = $this->get_child_line_item($line_item->code()); |
|
561 | + if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) { |
|
562 | + $this->delete_child_line_item($line_item_with_same_code->code()); |
|
563 | 563 | } |
564 | - $line_item->set_parent_ID( $this->ID() ); |
|
565 | - if( $this->TXN_ID() ){ |
|
566 | - $line_item->set_TXN_ID( $this->TXN_ID() ); |
|
564 | + $line_item->set_parent_ID($this->ID()); |
|
565 | + if ($this->TXN_ID()) { |
|
566 | + $line_item->set_TXN_ID($this->TXN_ID()); |
|
567 | 567 | } |
568 | 568 | return $line_item->save(); |
569 | 569 | } else { |
570 | - $this->_children[ $line_item->code() ] = $line_item; |
|
571 | - if( $line_item->parent() != $this ) { |
|
572 | - $line_item->set_parent( $this ); |
|
570 | + $this->_children[$line_item->code()] = $line_item; |
|
571 | + if ($line_item->parent() != $this) { |
|
572 | + $line_item->set_parent($this); |
|
573 | 573 | } |
574 | 574 | return TRUE; |
575 | 575 | } |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * @param EE_Line_Item $line_item |
584 | 584 | * |
585 | 585 | */ |
586 | - public function set_parent( $line_item ) { |
|
587 | - if ( $this->ID() ) { |
|
588 | - if( ! $line_item->ID() ) { |
|
586 | + public function set_parent($line_item) { |
|
587 | + if ($this->ID()) { |
|
588 | + if ( ! $line_item->ID()) { |
|
589 | 589 | $line_item->save(); |
590 | 590 | } |
591 | - $this->set_parent_ID( $line_item->ID() ); |
|
591 | + $this->set_parent_ID($line_item->ID()); |
|
592 | 592 | $this->save(); |
593 | 593 | } else { |
594 | 594 | $this->_parent = $line_item; |
595 | - $this->set_parent_ID( $line_item->ID() ); |
|
595 | + $this->set_parent_ID($line_item->ID()); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | * @param string $code |
606 | 606 | * @return EE_Line_Item |
607 | 607 | */ |
608 | - public function get_child_line_item( $code ) { |
|
609 | - if ( $this->ID() ) { |
|
610 | - return $this->get_model()->get_one( array( array( 'LIN_parent' => $this->ID(), 'LIN_code' => $code ) ) ); |
|
608 | + public function get_child_line_item($code) { |
|
609 | + if ($this->ID()) { |
|
610 | + return $this->get_model()->get_one(array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code))); |
|
611 | 611 | } else { |
612 | - return isset( $this->_children[ $code ] ) ? $this->_children[ $code ] : null; |
|
612 | + return isset($this->_children[$code]) ? $this->_children[$code] : null; |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
@@ -620,10 +620,10 @@ discard block |
||
620 | 620 | * @return int |
621 | 621 | */ |
622 | 622 | public function delete_children_line_items() { |
623 | - if ( $this->ID() ) { |
|
624 | - return $this->get_model()->delete( array( array( 'LIN_parent' => $this->ID() ) ) ); |
|
623 | + if ($this->ID()) { |
|
624 | + return $this->get_model()->delete(array(array('LIN_parent' => $this->ID()))); |
|
625 | 625 | } else { |
626 | - $count = count( $this->_children ); |
|
626 | + $count = count($this->_children); |
|
627 | 627 | $this->_children = array(); |
628 | 628 | return $count; |
629 | 629 | } |
@@ -640,25 +640,25 @@ discard block |
||
640 | 640 | * @param bool $stop_search_once_found |
641 | 641 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
642 | 642 | */ |
643 | - public function delete_child_line_item( $code, $stop_search_once_found = true ) { |
|
644 | - if ( $this->ID() ) { |
|
643 | + public function delete_child_line_item($code, $stop_search_once_found = true) { |
|
644 | + if ($this->ID()) { |
|
645 | 645 | $items_deleted = 0; |
646 | - if( $this->code() == $code ) { |
|
647 | - $items_deleted += EEH_Line_Item::delete_all_child_items( $this ); |
|
646 | + if ($this->code() == $code) { |
|
647 | + $items_deleted += EEH_Line_Item::delete_all_child_items($this); |
|
648 | 648 | $items_deleted += (int) $this->delete(); |
649 | - if( $stop_search_once_found ){ |
|
649 | + if ($stop_search_once_found) { |
|
650 | 650 | return $items_deleted; |
651 | 651 | } |
652 | 652 | } |
653 | - foreach( $this->children() as $child_line_item ) { |
|
654 | - $items_deleted += $child_line_item->delete_child_line_item( $code, $stop_search_once_found ); |
|
653 | + foreach ($this->children() as $child_line_item) { |
|
654 | + $items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found); |
|
655 | 655 | } |
656 | 656 | return $items_deleted; |
657 | 657 | } else { |
658 | - if( isset( $this->_children[ $code ] ) ) { |
|
659 | - unset( $this->_children[ $code ] ); |
|
658 | + if (isset($this->_children[$code])) { |
|
659 | + unset($this->_children[$code]); |
|
660 | 660 | return 1; |
661 | - }else{ |
|
661 | + } else { |
|
662 | 662 | return 0; |
663 | 663 | } |
664 | 664 | } |
@@ -671,9 +671,9 @@ discard block |
||
671 | 671 | * @return boolean |
672 | 672 | */ |
673 | 673 | public function delete_if_childless_subtotal() { |
674 | - if( $this->ID() && |
|
674 | + if ($this->ID() && |
|
675 | 675 | $this->type() == EEM_Line_Item::type_sub_total && |
676 | - ! $this->children() ) { |
|
676 | + ! $this->children()) { |
|
677 | 677 | return $this->delete(); |
678 | 678 | } else { |
679 | 679 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | */ |
689 | 689 | public function generate_code() { |
690 | 690 | // each line item in the cart requires a unique identifier |
691 | - return md5( $this->get( 'OBJ_type' ) . $this->get( 'OBJ_ID' ) . microtime() ); |
|
691 | + return md5($this->get('OBJ_type').$this->get('OBJ_ID').microtime()); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * @return string like '2, 004.00', formatted according to the localized currency |
772 | 772 | */ |
773 | 773 | public function unit_price_no_code() { |
774 | - return $this->get_pretty( 'LIN_unit_price', 'no_currency_code' ); |
|
774 | + return $this->get_pretty('LIN_unit_price', 'no_currency_code'); |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | * @return string like '2, 004.00', formatted according to the localized currency |
782 | 782 | */ |
783 | 783 | public function total_no_code() { |
784 | - return $this->get_pretty( 'LIN_total', 'no_currency_code' ); |
|
784 | + return $this->get_pretty('LIN_total', 'no_currency_code'); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | |
@@ -801,17 +801,17 @@ discard block |
||
801 | 801 | $tax_total = $this->recalculate_taxes_and_tax_total(); |
802 | 802 | $total = $pre_tax_total + $tax_total; |
803 | 803 | // no negative totals plz |
804 | - $total = max( $total, 0 ); |
|
805 | - $this->set_total( $total ); |
|
804 | + $total = max($total, 0); |
|
805 | + $this->set_total($total); |
|
806 | 806 | //only update the related transaction's total |
807 | 807 | //if we intend to save this line item and its a grand total |
808 | - if( |
|
808 | + if ( |
|
809 | 809 | $this->allow_persist() && |
810 | 810 | $this->type() === EEM_Line_Item::type_total && |
811 | 811 | $this->transaction() instanceof EE_Transaction |
812 | - ){ |
|
813 | - $this->transaction()->set_total( $total ); |
|
814 | - if ( $this->transaction()->ID() ) { |
|
812 | + ) { |
|
813 | + $this->transaction()->set_total($total); |
|
814 | + if ($this->transaction()->ID()) { |
|
815 | 815 | $this->transaction()->save(); |
816 | 816 | } |
817 | 817 | } |
@@ -830,47 +830,47 @@ discard block |
||
830 | 830 | public function recalculate_pre_tax_total() { |
831 | 831 | $total = 0; |
832 | 832 | $my_children = $this->children(); |
833 | - $has_children = ! empty( $my_children ); |
|
834 | - if ( $has_children && $this->is_line_item() ) { |
|
835 | - $total = $this->_recalculate_pretax_total_for_line_item( $total, $my_children ); |
|
836 | - } elseif ( ! $has_children && ( $this->is_sub_line_item() || $this->is_line_item() ) ) { |
|
833 | + $has_children = ! empty($my_children); |
|
834 | + if ($has_children && $this->is_line_item()) { |
|
835 | + $total = $this->_recalculate_pretax_total_for_line_item($total, $my_children); |
|
836 | + } elseif ( ! $has_children && ($this->is_sub_line_item() || $this->is_line_item())) { |
|
837 | 837 | $total = $this->unit_price() * $this->quantity(); |
838 | - } elseif( $this->is_sub_total() || $this->is_total() ) { |
|
839 | - $total = $this->_recalculate_pretax_total_for_subtotal( $total, $my_children ); |
|
840 | - } elseif ( $this->is_tax_sub_total() || $this->is_tax() || $this->is_cancelled() ) { |
|
838 | + } elseif ($this->is_sub_total() || $this->is_total()) { |
|
839 | + $total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children); |
|
840 | + } elseif ($this->is_tax_sub_total() || $this->is_tax() || $this->is_cancelled()) { |
|
841 | 841 | // completely ignore tax totals, tax sub-totals, and cancelled line items, when calculating the pre-tax-total |
842 | 842 | return 0; |
843 | 843 | } |
844 | 844 | // ensure all non-line items and non-sub-line-items have a quantity of 1 (except for Events) |
845 | - if( |
|
845 | + if ( |
|
846 | 846 | ! $this->is_line_item() && |
847 | 847 | ! $this->is_sub_line_item() && |
848 | 848 | ! $this->is_cancellation() |
849 | 849 | ) { |
850 | - if ( $this->OBJ_type() !== 'Event' ) { |
|
851 | - $this->set_quantity( 1 ); |
|
850 | + if ($this->OBJ_type() !== 'Event') { |
|
851 | + $this->set_quantity(1); |
|
852 | 852 | } |
853 | - if( ! $this->is_percent() ) { |
|
854 | - $this->set_unit_price( $this->total() ); |
|
853 | + if ( ! $this->is_percent()) { |
|
854 | + $this->set_unit_price($this->total()); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
858 | 858 | //we don't want to bother saving grand totals, because that needs to factor in taxes anyways |
859 | 859 | //so it ought to be |
860 | - if( ! $this->is_total() ) { |
|
861 | - $this->set_total( $total ); |
|
860 | + if ( ! $this->is_total()) { |
|
861 | + $this->set_total($total); |
|
862 | 862 | //if not a percent line item, make sure we keep the unit price in sync |
863 | - if( |
|
863 | + if ( |
|
864 | 864 | $has_children |
865 | 865 | && $this->is_line_item() |
866 | 866 | && ! $this->is_percent() |
867 | 867 | ) { |
868 | - if( $this->quantity() === 0 ){ |
|
868 | + if ($this->quantity() === 0) { |
|
869 | 869 | $new_unit_price = 0; |
870 | 870 | } else { |
871 | 871 | $new_unit_price = $this->total() / $this->quantity(); |
872 | 872 | } |
873 | - $this->set_unit_price( $new_unit_price ); |
|
873 | + $this->set_unit_price($new_unit_price); |
|
874 | 874 | } |
875 | 875 | $this->maybe_save(); |
876 | 876 | } |
@@ -890,39 +890,39 @@ discard block |
||
890 | 890 | * @return float |
891 | 891 | * @throws \EE_Error |
892 | 892 | */ |
893 | - protected function _recalculate_pretax_total_for_subtotal( $calculated_total_so_far, $my_children = null ) { |
|
894 | - if( $my_children === null ) { |
|
893 | + protected function _recalculate_pretax_total_for_subtotal($calculated_total_so_far, $my_children = null) { |
|
894 | + if ($my_children === null) { |
|
895 | 895 | $my_children = $this->children(); |
896 | 896 | } |
897 | 897 | //get the total of all its children |
898 | - foreach ( $my_children as $child_line_item ) { |
|
899 | - if ( $child_line_item instanceof EE_Line_Item && ! $child_line_item->is_cancellation() ) { |
|
898 | + foreach ($my_children as $child_line_item) { |
|
899 | + if ($child_line_item instanceof EE_Line_Item && ! $child_line_item->is_cancellation()) { |
|
900 | 900 | // percentage line items are based on total so far |
901 | - if ( $child_line_item->is_percent() ) { |
|
901 | + if ($child_line_item->is_percent()) { |
|
902 | 902 | //round as we go so that the line items add up ok |
903 | 903 | $percent_total = round( |
904 | 904 | $calculated_total_so_far * $child_line_item->percent() / 100, |
905 | 905 | EE_Registry::instance()->CFG->currency->dec_plc |
906 | 906 | ); |
907 | - $child_line_item->set_total( $percent_total ); |
|
907 | + $child_line_item->set_total($percent_total); |
|
908 | 908 | //so far all percent line items should have a quantity of 1 |
909 | 909 | //(ie, no double percent discounts. Although that might be requested someday) |
910 | - $child_line_item->set_quantity( 1 ); |
|
910 | + $child_line_item->set_quantity(1); |
|
911 | 911 | $child_line_item->maybe_save(); |
912 | 912 | $calculated_total_so_far += $percent_total; |
913 | 913 | } else { |
914 | 914 | //verify flat sub-line-item quantities match their parent |
915 | - if( $child_line_item->is_sub_line_item() ) { |
|
916 | - $child_line_item->set_quantity( $this->quantity() ); |
|
915 | + if ($child_line_item->is_sub_line_item()) { |
|
916 | + $child_line_item->set_quantity($this->quantity()); |
|
917 | 917 | } |
918 | 918 | $calculated_total_so_far += $child_line_item->recalculate_pre_tax_total(); |
919 | 919 | } |
920 | 920 | } |
921 | 921 | } |
922 | 922 | |
923 | - if( $this->is_sub_total() ){ |
|
923 | + if ($this->is_sub_total()) { |
|
924 | 924 | // no negative totals plz |
925 | - $calculated_total_so_far = max( $calculated_total_so_far, 0 ); |
|
925 | + $calculated_total_so_far = max($calculated_total_so_far, 0); |
|
926 | 926 | } |
927 | 927 | return $calculated_total_so_far; |
928 | 928 | } |
@@ -940,8 +940,8 @@ discard block |
||
940 | 940 | * @return float |
941 | 941 | * @throws \EE_Error |
942 | 942 | */ |
943 | - protected function _recalculate_pretax_total_for_line_item( $calculated_total_so_far, $my_children = null ) { |
|
944 | - if( $my_children === null ) { |
|
943 | + protected function _recalculate_pretax_total_for_line_item($calculated_total_so_far, $my_children = null) { |
|
944 | + if ($my_children === null) { |
|
945 | 945 | $my_children = $this->children(); |
946 | 946 | } |
947 | 947 | //we need to keep track of the running total for a single item, |
@@ -949,10 +949,10 @@ discard block |
||
949 | 949 | $unit_price_for_total = 0; |
950 | 950 | $quantity_for_total = 1; |
951 | 951 | //get the total of all its children |
952 | - foreach ( $my_children as $child_line_item ) { |
|
953 | - if ( $child_line_item instanceof EE_Line_Item && |
|
952 | + foreach ($my_children as $child_line_item) { |
|
953 | + if ($child_line_item instanceof EE_Line_Item && |
|
954 | 954 | ! $child_line_item->is_cancellation()) { |
955 | - if ( $child_line_item->is_percent() ) { |
|
955 | + if ($child_line_item->is_percent()) { |
|
956 | 956 | //it should be the unit-price-so-far multiplied by teh percent multiplied by the quantity |
957 | 957 | //not total multiplied by percent, because that ignores rounding along-the-way |
958 | 958 | $percent_unit_price = round( |
@@ -960,17 +960,17 @@ discard block |
||
960 | 960 | EE_Registry::instance()->CFG->currency->dec_plc |
961 | 961 | ); |
962 | 962 | $percent_total = $percent_unit_price * $quantity_for_total; |
963 | - $child_line_item->set_total( $percent_total ); |
|
963 | + $child_line_item->set_total($percent_total); |
|
964 | 964 | //so far all percent line items should have a quantity of 1 |
965 | 965 | //(ie, no double percent discounts. Although that might be requested someday) |
966 | - $child_line_item->set_quantity( 1 ); |
|
966 | + $child_line_item->set_quantity(1); |
|
967 | 967 | $child_line_item->maybe_save(); |
968 | 968 | $calculated_total_so_far += $percent_total; |
969 | 969 | $unit_price_for_total += $percent_unit_price; |
970 | 970 | } else { |
971 | 971 | //verify flat sub-line-item quantities match their parent |
972 | - if( $child_line_item->is_sub_line_item() ) { |
|
973 | - $child_line_item->set_quantity( $this->quantity() ); |
|
972 | + if ($child_line_item->is_sub_line_item()) { |
|
973 | + $child_line_item->set_quantity($this->quantity()); |
|
974 | 974 | } |
975 | 975 | $quantity_for_total = $child_line_item->quantity(); |
976 | 976 | $calculated_total_so_far += $child_line_item->recalculate_pre_tax_total(); |
@@ -994,10 +994,10 @@ discard block |
||
994 | 994 | //calculate the pretax total |
995 | 995 | $taxable_total = $this->taxable_total(); |
996 | 996 | $tax_total = 0; |
997 | - foreach ( $taxes as $tax ) { |
|
997 | + foreach ($taxes as $tax) { |
|
998 | 998 | $total_on_this_tax = $taxable_total * $tax->percent() / 100; |
999 | 999 | //remember the total on this line item |
1000 | - $tax->set_total( $total_on_this_tax ); |
|
1000 | + $tax->set_total($total_on_this_tax); |
|
1001 | 1001 | $tax_total += $tax->total(); |
1002 | 1002 | } |
1003 | 1003 | $this->_recalculate_tax_sub_total(); |
@@ -1011,21 +1011,21 @@ discard block |
||
1011 | 1011 | * @return void |
1012 | 1012 | */ |
1013 | 1013 | private function _recalculate_tax_sub_total() { |
1014 | - if ( $this->is_tax_sub_total() ) { |
|
1014 | + if ($this->is_tax_sub_total()) { |
|
1015 | 1015 | $total = 0; |
1016 | 1016 | $total_percent = 0; |
1017 | 1017 | //simply loop through all its children (which should be taxes) and sum their total |
1018 | - foreach ( $this->children() as $child_tax ) { |
|
1019 | - if ( $child_tax instanceof EE_Line_Item ) { |
|
1018 | + foreach ($this->children() as $child_tax) { |
|
1019 | + if ($child_tax instanceof EE_Line_Item) { |
|
1020 | 1020 | $total += $child_tax->total(); |
1021 | 1021 | $total_percent += $child_tax->percent(); |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | - $this->set_total( $total ); |
|
1025 | - $this->set_percent( $total_percent ); |
|
1026 | - } elseif ( $this->is_total() ) { |
|
1027 | - foreach ( $this->children() as $maybe_tax_subtotal ) { |
|
1028 | - if ( $maybe_tax_subtotal instanceof EE_Line_Item ) { |
|
1024 | + $this->set_total($total); |
|
1025 | + $this->set_percent($total_percent); |
|
1026 | + } elseif ($this->is_total()) { |
|
1027 | + foreach ($this->children() as $maybe_tax_subtotal) { |
|
1028 | + if ($maybe_tax_subtotal instanceof EE_Line_Item) { |
|
1029 | 1029 | $maybe_tax_subtotal->_recalculate_tax_sub_total(); |
1030 | 1030 | } |
1031 | 1031 | } |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | public function get_total_tax() { |
1042 | 1042 | $this->_recalculate_tax_sub_total(); |
1043 | 1043 | $total = 0; |
1044 | - foreach ( $this->tax_descendants() as $tax_line_item ) { |
|
1045 | - if ( $tax_line_item instanceof EE_Line_Item ) { |
|
1044 | + foreach ($this->tax_descendants() as $tax_line_item) { |
|
1045 | + if ($tax_line_item instanceof EE_Line_Item) { |
|
1046 | 1046 | $total += $tax_line_item->total(); |
1047 | 1047 | } |
1048 | 1048 | } |
@@ -1056,15 +1056,15 @@ discard block |
||
1056 | 1056 | */ |
1057 | 1057 | public function get_items_total() { |
1058 | 1058 | //by default, let's make sure we're consistent with the existing line item |
1059 | - if( $this->is_total() ) { |
|
1060 | - $pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal( $this ); |
|
1061 | - if( $pretax_subtotal_li instanceof EE_Line_Item ) { |
|
1059 | + if ($this->is_total()) { |
|
1060 | + $pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal($this); |
|
1061 | + if ($pretax_subtotal_li instanceof EE_Line_Item) { |
|
1062 | 1062 | return $pretax_subtotal_li->total(); |
1063 | 1063 | } |
1064 | 1064 | } |
1065 | 1065 | $total = 0; |
1066 | - foreach ( $this->get_items() as $item ) { |
|
1067 | - if ( $item instanceof EE_Line_Item ) { |
|
1066 | + foreach ($this->get_items() as $item) { |
|
1067 | + if ($item instanceof EE_Line_Item) { |
|
1068 | 1068 | $total += $item->total(); |
1069 | 1069 | } |
1070 | 1070 | } |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | * @return EE_Line_Item[] |
1080 | 1080 | */ |
1081 | 1081 | public function tax_descendants() { |
1082 | - return EEH_Line_Item::get_tax_descendants( $this ); |
|
1082 | + return EEH_Line_Item::get_tax_descendants($this); |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | * @return EE_Line_Item[] |
1090 | 1090 | */ |
1091 | 1091 | public function get_items() { |
1092 | - return EEH_Line_Item::get_line_item_descendants( $this ); |
|
1092 | + return EEH_Line_Item::get_line_item_descendants($this); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | |
@@ -1105,22 +1105,22 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | public function taxable_total() { |
1107 | 1107 | $total = 0; |
1108 | - if ( $this->children() ) { |
|
1109 | - foreach ( $this->children() as $child_line_item ) { |
|
1110 | - if ( $child_line_item->type() === EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) { |
|
1108 | + if ($this->children()) { |
|
1109 | + foreach ($this->children() as $child_line_item) { |
|
1110 | + if ($child_line_item->type() === EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) { |
|
1111 | 1111 | //if it's a percent item, only take into account the percent |
1112 | 1112 | //that's taxable too (the taxable total so far) |
1113 | - if( $child_line_item->is_percent() ) { |
|
1114 | - $total = $total + ( $total * $child_line_item->percent() / 100 ); |
|
1115 | - }else{ |
|
1113 | + if ($child_line_item->is_percent()) { |
|
1114 | + $total = $total + ($total * $child_line_item->percent() / 100); |
|
1115 | + } else { |
|
1116 | 1116 | $total += $child_line_item->total(); |
1117 | 1117 | } |
1118 | - }elseif( $child_line_item->type() === EEM_Line_Item::type_sub_total ){ |
|
1118 | + }elseif ($child_line_item->type() === EEM_Line_Item::type_sub_total) { |
|
1119 | 1119 | $total += $child_line_item->taxable_total(); |
1120 | 1120 | } |
1121 | 1121 | } |
1122 | 1122 | } |
1123 | - return max( $total, 0 ); |
|
1123 | + return max($total, 0); |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | * @return EE_Transaction |
1131 | 1131 | */ |
1132 | 1132 | public function transaction() { |
1133 | - return $this->get_first_related( 'Transaction' ); |
|
1133 | + return $this->get_first_related('Transaction'); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | |
@@ -1143,18 +1143,18 @@ discard block |
||
1143 | 1143 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
1144 | 1144 | * @return int count of items saved |
1145 | 1145 | */ |
1146 | - public function save_this_and_descendants_to_txn( $txn_id = NULL ) { |
|
1146 | + public function save_this_and_descendants_to_txn($txn_id = NULL) { |
|
1147 | 1147 | $count = 0; |
1148 | - if ( ! $txn_id ) { |
|
1148 | + if ( ! $txn_id) { |
|
1149 | 1149 | $txn_id = $this->TXN_ID(); |
1150 | 1150 | } |
1151 | - $this->set_TXN_ID( $txn_id ); |
|
1151 | + $this->set_TXN_ID($txn_id); |
|
1152 | 1152 | $children = $this->children(); |
1153 | 1153 | $count += $this->save() ? 1 : 0; |
1154 | - foreach ( $children as $child_line_item ) { |
|
1155 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1156 | - $child_line_item->set_parent_ID( $this->ID() ); |
|
1157 | - $count += $child_line_item->save_this_and_descendants_to_txn( $txn_id ); |
|
1154 | + foreach ($children as $child_line_item) { |
|
1155 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1156 | + $child_line_item->set_parent_ID($this->ID()); |
|
1157 | + $count += $child_line_item->save_this_and_descendants_to_txn($txn_id); |
|
1158 | 1158 | } |
1159 | 1159 | } |
1160 | 1160 | return $count; |
@@ -1171,9 +1171,9 @@ discard block |
||
1171 | 1171 | $count = 0; |
1172 | 1172 | $children = $this->children(); |
1173 | 1173 | $count += $this->save() ? 1 : 0; |
1174 | - foreach ( $children as $child_line_item ) { |
|
1175 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1176 | - $child_line_item->set_parent_ID( $this->ID() ); |
|
1174 | + foreach ($children as $child_line_item) { |
|
1175 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1176 | + $child_line_item->set_parent_ID($this->ID()); |
|
1177 | 1177 | $count += $child_line_item->save_this_and_descendants(); |
1178 | 1178 | } |
1179 | 1179 | } |
@@ -1187,8 +1187,8 @@ discard block |
||
1187 | 1187 | * @return EE_Line_Item[] |
1188 | 1188 | */ |
1189 | 1189 | function get_cancellations() { |
1190 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1191 | - return EEH_Line_Item::get_descendants_of_type( $this, EEM_Line_Item::type_cancellation ); |
|
1190 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1191 | + return EEH_Line_Item::get_descendants_of_type($this, EEM_Line_Item::type_cancellation); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | |
@@ -1198,9 +1198,9 @@ discard block |
||
1198 | 1198 | * @param string $type one of the constants on EEM_Line_Item |
1199 | 1199 | * @return EE_Line_Item[] |
1200 | 1200 | */ |
1201 | - protected function _get_descendants_of_type( $type ) { |
|
1202 | - EE_Error::doing_it_wrong( 'EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0' ); |
|
1203 | - return EEH_Line_Item::get_descendants_of_type( $this, $type ); |
|
1201 | + protected function _get_descendants_of_type($type) { |
|
1202 | + EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'); |
|
1203 | + return EEH_Line_Item::get_descendants_of_type($this, $type); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | |
@@ -1210,9 +1210,9 @@ discard block |
||
1210 | 1210 | * @param string $type like one of the EEM_Line_Item::type_* |
1211 | 1211 | * @return EE_Line_Item |
1212 | 1212 | */ |
1213 | - public function get_nearest_descendant_of_type( $type ) { |
|
1214 | - EE_Error::doing_it_wrong( 'EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0' ); |
|
1215 | - return EEH_Line_Item::get_nearest_descendant_of_type( $this, $type ); |
|
1213 | + public function get_nearest_descendant_of_type($type) { |
|
1214 | + EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'); |
|
1215 | + return EEH_Line_Item::get_nearest_descendant_of_type($this, $type); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | * @return int count of items saved |
1224 | 1224 | */ |
1225 | 1225 | public function maybe_save() { |
1226 | - if ( $this->ID() ) { |
|
1226 | + if ($this->ID()) { |
|
1227 | 1227 | return $this->save(); |
1228 | 1228 | } |
1229 | 1229 | return false; |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | * @param bool $bydb |
113 | 113 | * @return \EE_Base_Class |
114 | 114 | */ |
115 | - public static function new_instance( $fieldValues = array(), $timezone = '', $date_formats = array(), $bydb = false ) { |
|
115 | + public static function new_instance($fieldValues = array(), $timezone = '', $date_formats = array(), $bydb = false) { |
|
116 | 116 | $className = get_called_class(); |
117 | - if ( ! $bydb ) { |
|
118 | - $cached_object = \EE_Base_Class::_check_for_object( $fieldValues, $className, $timezone, $date_formats ); |
|
119 | - if ( $cached_object ) { |
|
117 | + if ( ! $bydb) { |
|
118 | + $cached_object = \EE_Base_Class::_check_for_object($fieldValues, $className, $timezone, $date_formats); |
|
119 | + if ($cached_object) { |
|
120 | 120 | return $cached_object; |
121 | 121 | } |
122 | 122 | } |
123 | - return new static( $fieldValues, $bydb, $timezone, $date_formats ); |
|
123 | + return new static($fieldValues, $bydb, $timezone, $date_formats); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param array $date_formats |
133 | 133 | * @return \EE_Base_Class |
134 | 134 | */ |
135 | - public static function new_instance_from_db( $fieldValues = array(), $timezone = '', $date_formats = array() ) { |
|
136 | - return static::new_instance( $fieldValues, $timezone, $date_formats, true ); |
|
135 | + public static function new_instance_from_db($fieldValues = array(), $timezone = '', $date_formats = array()) { |
|
136 | + return static::new_instance($fieldValues, $timezone, $date_formats, true); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -155,56 +155,56 @@ discard block |
||
155 | 155 | * @throws \EE_Error |
156 | 156 | * @throws \Exception |
157 | 157 | */ |
158 | - protected function __construct( $fieldValues = array(), $bydb = false, $timezone = '', $date_formats = array() ){ |
|
158 | + protected function __construct($fieldValues = array(), $bydb = false, $timezone = '', $date_formats = array()) { |
|
159 | 159 | $className = get_class($this); |
160 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
161 | - $model=$this->get_model(); |
|
162 | - $model_fields = $model->field_settings( FALSE ); |
|
160 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
161 | + $model = $this->get_model(); |
|
162 | + $model_fields = $model->field_settings(FALSE); |
|
163 | 163 | // ensure $fieldValues is an array |
164 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
164 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
165 | 165 | // verify client code has not passed any invalid field names |
166 | - foreach($fieldValues as $field_name=> $field_value){ |
|
167 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
168 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
166 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
167 | + if ( ! isset($model_fields[$field_name])) { |
|
168 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
172 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
172 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
173 | 173 | |
174 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
174 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
175 | 175 | $this->_dt_frmt = $date_formats[0]; |
176 | 176 | $this->_tm_frmt = $date_formats[1]; |
177 | 177 | } else { |
178 | 178 | //set default formats for date and time |
179 | - $this->_dt_frmt = get_option( 'date_format' ); |
|
180 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
179 | + $this->_dt_frmt = get_option('date_format'); |
|
180 | + $this->_tm_frmt = get_option('time_format'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | //if db model is instantiating |
184 | - if ( $bydb ){ |
|
184 | + if ($bydb) { |
|
185 | 185 | //client code has indicated these field values are from the database |
186 | - foreach( $model_fields as $fieldName => $field ){ |
|
187 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
186 | + foreach ($model_fields as $fieldName => $field) { |
|
187 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
188 | 188 | } |
189 | 189 | } else { |
190 | 190 | //we're constructing a brand |
191 | 191 | //new instance of the model object. Generally, this means we'll need to do more field validation |
192 | - foreach( $model_fields as $fieldName => $field ){ |
|
193 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
192 | + foreach ($model_fields as $fieldName => $field) { |
|
193 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | //remember what values were passed to this constructor |
198 | 198 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
199 | 199 | //remember in entity mapper |
200 | - if( ! $bydb && $model->has_primary_key_field() && $this->ID() ){ |
|
200 | + if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) { |
|
201 | 201 | $model->add_to_entity_map($this); |
202 | 202 | } |
203 | 203 | //setup all the relations |
204 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
205 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
204 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
205 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
206 | 206 | $this->_model_relations[$relation_name] = NULL; |
207 | - }else{ |
|
207 | + } else { |
|
208 | 208 | $this->_model_relations[$relation_name] = array(); |
209 | 209 | } |
210 | 210 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * Action done at the end of each model object construction |
213 | 213 | * @param EE_Base_Class $this the model object just created |
214 | 214 | */ |
215 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
215 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param boolean $allow_persist |
233 | 233 | * @return boolean |
234 | 234 | */ |
235 | - public function set_allow_persist( $allow_persist ) { |
|
235 | + public function set_allow_persist($allow_persist) { |
|
236 | 236 | return $this->_allow_persist = $allow_persist; |
237 | 237 | } |
238 | 238 | |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | * @return mixed|null |
247 | 247 | * @throws \EE_Error |
248 | 248 | */ |
249 | - public function get_original( $field_name ){ |
|
250 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
251 | - $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
|
252 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
253 | - }else{ |
|
249 | + public function get_original($field_name) { |
|
250 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
251 | + $field_settings = $this->get_model()->field_settings_for($field_name)) { |
|
252 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
253 | + } else { |
|
254 | 254 | return NULL; |
255 | 255 | } |
256 | 256 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param EE_Base_Class $obj |
261 | 261 | * @return string |
262 | 262 | */ |
263 | - public function get_class($obj){ |
|
263 | + public function get_class($obj) { |
|
264 | 264 | return get_class($obj); |
265 | 265 | } |
266 | 266 | |
@@ -275,19 +275,19 @@ discard block |
||
275 | 275 | * @param bool $use_default |
276 | 276 | * @throws \EE_Error |
277 | 277 | */ |
278 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
279 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
280 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
278 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
279 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
280 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
281 | 281 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
282 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
283 | - $field_obj->set_timezone( $this->_timezone ); |
|
284 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
285 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
282 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
283 | + $field_obj->set_timezone($this->_timezone); |
|
284 | + $field_obj->set_date_format($this->_dt_frmt); |
|
285 | + $field_obj->set_time_format($this->_tm_frmt); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
289 | 289 | //should the value be null? |
290 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
290 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
291 | 291 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
292 | 292 | |
293 | 293 | /** |
@@ -299,26 +299,26 @@ discard block |
||
299 | 299 | */ |
300 | 300 | if ( |
301 | 301 | $field_obj instanceof EE_Datetime_Field |
302 | - && $this->_fields[ $field_name ] !== null |
|
302 | + && $this->_fields[$field_name] !== null |
|
303 | 303 | && ! $this->_fields[$field_name] instanceof DateTime |
304 | 304 | ) { |
305 | - empty( $this->_fields[$field_name] ) |
|
306 | - ? $this->set( $field_name, time() ) |
|
307 | - : $this->set( $field_name, $this->_fields[$field_name] ); |
|
305 | + empty($this->_fields[$field_name]) |
|
306 | + ? $this->set($field_name, time()) |
|
307 | + : $this->set($field_name, $this->_fields[$field_name]); |
|
308 | 308 | } |
309 | 309 | |
310 | - }else{ |
|
310 | + } else { |
|
311 | 311 | $this->_fields[$field_name] = $holder_of_value; |
312 | 312 | } |
313 | 313 | |
314 | 314 | //if we're not in the constructor... |
315 | 315 | //now check if what we set was a primary key |
316 | - if( |
|
316 | + if ( |
|
317 | 317 | //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
318 | 318 | $this->_props_n_values_provided_in_constructor |
319 | 319 | && $field_value |
320 | - && $field_name === self::_get_primary_key_name( get_class( $this ) ) |
|
321 | - ){ |
|
320 | + && $field_name === self::_get_primary_key_name(get_class($this)) |
|
321 | + ) { |
|
322 | 322 | //if so, we want all this object's fields to be filled either with |
323 | 323 | //what we've explicitly set on this model |
324 | 324 | //or what we have in the db |
@@ -326,20 +326,20 @@ discard block |
||
326 | 326 | $fields_on_model = self::_get_model(get_class($this))->field_settings(); |
327 | 327 | |
328 | 328 | $obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value); |
329 | - foreach($fields_on_model as $field_obj){ |
|
330 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
331 | - && $field_obj->get_name() !== $field_name ){ |
|
329 | + foreach ($fields_on_model as $field_obj) { |
|
330 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
331 | + && $field_obj->get_name() !== $field_name) { |
|
332 | 332 | |
333 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
333 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | //oh this model object has an ID? well make sure its in the entity mapper |
337 | 337 | $this->get_model()->add_to_entity_map($this); |
338 | 338 | } |
339 | 339 | //let's unset any cache for this field_name from the $_cached_properties property. |
340 | - $this->_clear_cached_property( $field_name ); |
|
341 | - }else{ |
|
342 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
340 | + $this->_clear_cached_property($field_name); |
|
341 | + } else { |
|
342 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | } |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
360 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
361 | - $this->set( $field_name, $field_value ); |
|
359 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
360 | + if ($this->get_model()->has_field($field_name)) { |
|
361 | + $this->set($field_name, $field_value); |
|
362 | 362 | return true; |
363 | 363 | } else { |
364 | 364 | //ensure this object is saved first so that extra meta can be properly related. |
365 | 365 | $this->save(); |
366 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
366 | + return $this->update_extra_meta($field_name, $field_value); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | * @return mixed|null value for the field if found. null if not found. |
385 | 385 | * @throws \EE_Error |
386 | 386 | */ |
387 | - public function get_field_or_extra_meta( $field_name ) { |
|
388 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
389 | - $column_value = $this->get( $field_name ); |
|
387 | + public function get_field_or_extra_meta($field_name) { |
|
388 | + if ($this->get_model()->has_field($field_name)) { |
|
389 | + $column_value = $this->get($field_name); |
|
390 | 390 | } else { |
391 | 391 | //This isn't a column in the main table, let's see if it is in the extra meta. |
392 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
392 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
393 | 393 | } |
394 | 394 | return $column_value; |
395 | 395 | } |
@@ -405,18 +405,18 @@ discard block |
||
405 | 405 | * @return void |
406 | 406 | * @throws \EE_Error |
407 | 407 | */ |
408 | - public function set_timezone( $timezone = '' ) { |
|
409 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
408 | + public function set_timezone($timezone = '') { |
|
409 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
410 | 410 | //make sure we clear all cached properties because they won't be relevant now |
411 | 411 | $this->_clear_cached_properties(); |
412 | 412 | |
413 | 413 | //make sure we update field settings and the date for all EE_Datetime_Fields |
414 | - $model_fields = $this->get_model()->field_settings( false ); |
|
415 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
416 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
417 | - $field_obj->set_timezone( $this->_timezone ); |
|
418 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
419 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
414 | + $model_fields = $this->get_model()->field_settings(false); |
|
415 | + foreach ($model_fields as $field_name => $field_obj) { |
|
416 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
417 | + $field_obj->set_timezone($this->_timezone); |
|
418 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
419 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param string $format should be a format recognizable by PHP date() functions. |
447 | 447 | */ |
448 | - public function set_date_format( $format ) { |
|
448 | + public function set_date_format($format) { |
|
449 | 449 | $this->_dt_frmt = $format; |
450 | 450 | //clear cached_properties because they won't be relevant now. |
451 | 451 | $this->_clear_cached_properties(); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @since 4.6 |
462 | 462 | * @param string $format should be a format recognizable by PHP date() functions. |
463 | 463 | */ |
464 | - public function set_time_format( $format ) { |
|
464 | + public function set_time_format($format) { |
|
465 | 465 | $this->_tm_frmt = $format; |
466 | 466 | //clear cached_properties because they won't be relevant now. |
467 | 467 | $this->_clear_cached_properties(); |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return mixed string|array |
480 | 480 | */ |
481 | - public function get_format( $full = true ) { |
|
482 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
481 | + public function get_format($full = true) { |
|
482 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -497,17 +497,17 @@ discard block |
||
497 | 497 | * @throws EE_Error |
498 | 498 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
499 | 499 | */ |
500 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
500 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
501 | 501 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
502 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
502 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
503 | 503 | return FALSE; |
504 | 504 | } |
505 | 505 | // also get "how" the object is related, or throw an error |
506 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
507 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
506 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
507 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
508 | 508 | } |
509 | 509 | // how many things are related ? |
510 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
510 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
511 | 511 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
512 | 512 | // so for these model objects just set it to be cached |
513 | 513 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -515,26 +515,26 @@ discard block |
||
515 | 515 | } else { |
516 | 516 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
517 | 517 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
518 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
518 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
519 | 519 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
520 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
520 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
521 | 521 | } |
522 | 522 | // first check for a cache_id which is normally empty |
523 | - if ( ! empty( $cache_id )) { |
|
523 | + if ( ! empty($cache_id)) { |
|
524 | 524 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
525 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
525 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
526 | 526 | $return = $cache_id; |
527 | - } elseif ( $object_to_cache->ID() ) { |
|
527 | + } elseif ($object_to_cache->ID()) { |
|
528 | 528 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
529 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
529 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
530 | 530 | $return = $object_to_cache->ID(); |
531 | 531 | } else { |
532 | 532 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
533 | 533 | $this->_model_relations[$relationName][] = $object_to_cache; |
534 | 534 | // move the internal pointer to the end of the array |
535 | - end( $this->_model_relations[$relationName] ); |
|
535 | + end($this->_model_relations[$relationName]); |
|
536 | 536 | // and grab the key so that we can return it |
537 | - $return = key( $this->_model_relations[$relationName] ); |
|
537 | + $return = key($this->_model_relations[$relationName]); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | } |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | * @return void |
554 | 554 | * @throws \EE_Error |
555 | 555 | */ |
556 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
556 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
557 | 557 | //first make sure this property exists |
558 | 558 | $this->get_model()->field_settings_for($fieldname); |
559 | 559 | |
560 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
560 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
561 | 561 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
562 | 562 | } |
563 | 563 | |
@@ -578,36 +578,36 @@ discard block |
||
578 | 578 | * @return mixed whatever the value for the property is we're retrieving |
579 | 579 | * @throws \EE_Error |
580 | 580 | */ |
581 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
581 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
582 | 582 | //verify the field exists |
583 | 583 | $this->get_model()->field_settings_for($fieldname); |
584 | 584 | |
585 | 585 | $cache_type = $pretty ? 'pretty' : 'standard'; |
586 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
586 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
587 | 587 | |
588 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
588 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
589 | 589 | return $this->_cached_properties[$fieldname][$cache_type]; |
590 | 590 | } |
591 | 591 | |
592 | 592 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
593 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
593 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
594 | 594 | /** |
595 | 595 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
596 | 596 | * formats are correct. |
597 | 597 | */ |
598 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
599 | - $field_obj->set_timezone( $this->_timezone ); |
|
600 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
601 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
598 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
599 | + $field_obj->set_timezone($this->_timezone); |
|
600 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
601 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
602 | 602 | } |
603 | 603 | |
604 | - if( ! isset($this->_fields[$fieldname])){ |
|
604 | + if ( ! isset($this->_fields[$fieldname])) { |
|
605 | 605 | $this->_fields[$fieldname] = NULL; |
606 | 606 | } |
607 | 607 | $value = $pretty |
608 | 608 | ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) |
609 | - : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
610 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
609 | + : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
610 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
611 | 611 | return $value; |
612 | 612 | } |
613 | 613 | return null; |
@@ -633,9 +633,9 @@ discard block |
||
633 | 633 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
634 | 634 | * @return void |
635 | 635 | */ |
636 | - protected function _clear_cached_property( $property_name ) { |
|
637 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
638 | - unset( $this->_cached_properties[ $property_name ] ); |
|
636 | + protected function _clear_cached_property($property_name) { |
|
637 | + if (isset($this->_cached_properties[$property_name])) { |
|
638 | + unset($this->_cached_properties[$property_name]); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -649,12 +649,12 @@ discard block |
||
649 | 649 | * @return EE_Base_Class |
650 | 650 | * @throws \EE_Error |
651 | 651 | */ |
652 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
652 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
653 | 653 | $other_model_instance = self::_get_model_instance_with_name( |
654 | - self::_get_model_classname( $model_name ), |
|
654 | + self::_get_model_classname($model_name), |
|
655 | 655 | $this->_timezone |
656 | 656 | ); |
657 | - return $other_model_instance->ensure_is_obj( $object_or_id ); |
|
657 | + return $other_model_instance->ensure_is_obj($object_or_id); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -671,32 +671,32 @@ discard block |
||
671 | 671 | * @throws EE_Error |
672 | 672 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
673 | 673 | */ |
674 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
674 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
675 | 675 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
676 | 676 | $index_in_cache = ''; |
677 | - if( ! $relationship_to_model){ |
|
677 | + if ( ! $relationship_to_model) { |
|
678 | 678 | throw new EE_Error( |
679 | 679 | sprintf( |
680 | - __( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ), |
|
680 | + __("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), |
|
681 | 681 | $relationName, |
682 | - get_class( $this ) |
|
682 | + get_class($this) |
|
683 | 683 | ) |
684 | 684 | ); |
685 | 685 | } |
686 | - if($clear_all){ |
|
686 | + if ($clear_all) { |
|
687 | 687 | $obj_removed = true; |
688 | 688 | $this->_model_relations[$relationName] = null; |
689 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
689 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
690 | 690 | $obj_removed = $this->_model_relations[$relationName]; |
691 | 691 | $this->_model_relations[$relationName] = null; |
692 | - }else{ |
|
693 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
692 | + } else { |
|
693 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
694 | 694 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
695 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
695 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
696 | 696 | $index_found_at = NULL; |
697 | 697 | //find this object in the array even though it has a different key |
698 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
699 | - if( |
|
698 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
699 | + if ( |
|
700 | 700 | $obj instanceof EE_Base_Class |
701 | 701 | && ( |
702 | 702 | $obj == $object_to_remove_or_index_into_array |
@@ -707,34 +707,34 @@ discard block |
||
707 | 707 | break; |
708 | 708 | } |
709 | 709 | } |
710 | - if($index_found_at){ |
|
710 | + if ($index_found_at) { |
|
711 | 711 | $index_in_cache = $index_found_at; |
712 | - }else{ |
|
712 | + } else { |
|
713 | 713 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
714 | 714 | //if it wasn't in it to begin with. So we're done |
715 | 715 | return $object_to_remove_or_index_into_array; |
716 | 716 | } |
717 | 717 | } |
718 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
718 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
719 | 719 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
720 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
721 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
720 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
721 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
722 | 722 | $index_in_cache = $index; |
723 | 723 | } |
724 | 724 | } |
725 | - }else{ |
|
725 | + } else { |
|
726 | 726 | $index_in_cache = $object_to_remove_or_index_into_array; |
727 | 727 | } |
728 | 728 | //supposedly we've found it. But it could just be that the client code |
729 | 729 | //provided a bad index/object |
730 | 730 | if ( |
731 | 731 | isset( |
732 | - $this->_model_relations[ $relationName ], |
|
733 | - $this->_model_relations[ $relationName ][ $index_in_cache ] |
|
732 | + $this->_model_relations[$relationName], |
|
733 | + $this->_model_relations[$relationName][$index_in_cache] |
|
734 | 734 | ) |
735 | 735 | ) { |
736 | - $obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ]; |
|
737 | - unset( $this->_model_relations[ $relationName ][ $index_in_cache ] ); |
|
736 | + $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
|
737 | + unset($this->_model_relations[$relationName][$index_in_cache]); |
|
738 | 738 | } else { |
739 | 739 | //that thing was never cached anyways. |
740 | 740 | $obj_removed = null; |
@@ -755,24 +755,24 @@ discard block |
||
755 | 755 | * @return boolean TRUE on success, FALSE on fail |
756 | 756 | * @throws \EE_Error |
757 | 757 | */ |
758 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
758 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
759 | 759 | // verify that incoming object is of the correct type |
760 | - $obj_class = 'EE_' . $relationName; |
|
761 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
760 | + $obj_class = 'EE_'.$relationName; |
|
761 | + if ($newly_saved_object instanceof $obj_class) { |
|
762 | 762 | /* @type EE_Base_Class $newly_saved_object*/ |
763 | 763 | // now get the type of relation |
764 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
764 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
765 | 765 | // if this is a 1:1 relationship |
766 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
766 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
767 | 767 | // then just replace the cached object with the newly saved object |
768 | 768 | $this->_model_relations[$relationName] = $newly_saved_object; |
769 | 769 | return TRUE; |
770 | 770 | // or if it's some kind of sordid feral polyamorous relationship... |
771 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
771 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
772 | 772 | // then remove the current cached item |
773 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
773 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
774 | 774 | // and cache the newly saved object using it's new ID |
775 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
775 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
776 | 776 | return TRUE; |
777 | 777 | } |
778 | 778 | } |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | * @param string $relationName |
789 | 789 | * @return EE_Base_Class |
790 | 790 | */ |
791 | - public function get_one_from_cache($relationName){ |
|
792 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
793 | - if(is_array($cached_array_or_object)){ |
|
791 | + public function get_one_from_cache($relationName) { |
|
792 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
793 | + if (is_array($cached_array_or_object)) { |
|
794 | 794 | return array_shift($cached_array_or_object); |
795 | - }else{ |
|
795 | + } else { |
|
796 | 796 | return $cached_array_or_object; |
797 | 797 | } |
798 | 798 | } |
@@ -807,23 +807,23 @@ discard block |
||
807 | 807 | * @throws \EE_Error |
808 | 808 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
809 | 809 | */ |
810 | - public function get_all_from_cache($relationName){ |
|
811 | - $objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
810 | + public function get_all_from_cache($relationName) { |
|
811 | + $objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
812 | 812 | // if the result is not an array, but exists, make it an array |
813 | - $objects = is_array( $objects ) ? $objects : array( $objects ); |
|
813 | + $objects = is_array($objects) ? $objects : array($objects); |
|
814 | 814 | //bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143 |
815 | 815 | //basically, if this model object was stored in the session, and these cached model objects |
816 | 816 | //already have IDs, let's make sure they're in their model's entity mapper |
817 | 817 | //otherwise we will have duplicates next time we call |
818 | 818 | // EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
819 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
820 | - foreach( $objects as $model_object ){ |
|
821 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
819 | + $model = EE_Registry::instance()->load_model($relationName); |
|
820 | + foreach ($objects as $model_object) { |
|
821 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
822 | 822 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
823 | - if( $model_object->ID() ){ |
|
824 | - $model->add_to_entity_map( $model_object ); |
|
823 | + if ($model_object->ID()) { |
|
824 | + $model->add_to_entity_map($model_object); |
|
825 | 825 | } |
826 | - }else{ |
|
826 | + } else { |
|
827 | 827 | throw new EE_Error( |
828 | 828 | sprintf( |
829 | 829 | __( |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | 'event_espresso' |
832 | 832 | ), |
833 | 833 | $relationName, |
834 | - gettype( $model_object ) |
|
834 | + gettype($model_object) |
|
835 | 835 | ) |
836 | 836 | ); |
837 | 837 | } |
@@ -853,15 +853,15 @@ discard block |
||
853 | 853 | * @return array|EE_Base_Class[] |
854 | 854 | * @throws \EE_Error |
855 | 855 | */ |
856 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
857 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
856 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
857 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
858 | 858 | ? $this->get_model()->get_primary_key_field()->get_name() |
859 | 859 | : $field_to_order_by; |
860 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
861 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
860 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
861 | + if (empty($field) || empty($current_value)) { |
|
862 | 862 | return array(); |
863 | 863 | } |
864 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
864 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -878,15 +878,15 @@ discard block |
||
878 | 878 | * @return array|EE_Base_Class[] |
879 | 879 | * @throws \EE_Error |
880 | 880 | */ |
881 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
882 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
881 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
882 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
883 | 883 | ? $this->get_model()->get_primary_key_field()->get_name() |
884 | 884 | : $field_to_order_by; |
885 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
886 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
885 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
886 | + if (empty($field) || empty($current_value)) { |
|
887 | 887 | return array(); |
888 | 888 | } |
889 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
889 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
@@ -902,15 +902,15 @@ discard block |
||
902 | 902 | * @return array|EE_Base_Class |
903 | 903 | * @throws \EE_Error |
904 | 904 | */ |
905 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
906 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
905 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
906 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
907 | 907 | ? $this->get_model()->get_primary_key_field()->get_name() |
908 | 908 | : $field_to_order_by; |
909 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
910 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
909 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
910 | + if (empty($field) || empty($current_value)) { |
|
911 | 911 | return array(); |
912 | 912 | } |
913 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
913 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | |
@@ -926,15 +926,15 @@ discard block |
||
926 | 926 | * @return array|EE_Base_Class |
927 | 927 | * @throws \EE_Error |
928 | 928 | */ |
929 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
930 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
929 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
930 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
931 | 931 | ? $this->get_model()->get_primary_key_field()->get_name() |
932 | 932 | : $field_to_order_by; |
933 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
934 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
933 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
934 | + if (empty($field) || empty($current_value)) { |
|
935 | 935 | return array(); |
936 | 936 | } |
937 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
937 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | |
@@ -947,25 +947,25 @@ discard block |
||
947 | 947 | * @param mixed $field_value_from_db |
948 | 948 | * @throws \EE_Error |
949 | 949 | */ |
950 | - public function set_from_db($field_name,$field_value_from_db){ |
|
950 | + public function set_from_db($field_name, $field_value_from_db) { |
|
951 | 951 | $field_obj = $this->get_model()->field_settings_for($field_name); |
952 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
952 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
953 | 953 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
954 | 954 | //eg, a CPT model object could have an entry in the posts table, but no |
955 | 955 | //entry in the meta table. Meaning that all its columns in the meta table |
956 | 956 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
957 | - if($field_value_from_db === NULL ){ |
|
958 | - if( $field_obj->is_nullable()){ |
|
957 | + if ($field_value_from_db === NULL) { |
|
958 | + if ($field_obj->is_nullable()) { |
|
959 | 959 | //if the field allows nulls, then let it be null |
960 | 960 | $field_value = NULL; |
961 | - }else{ |
|
961 | + } else { |
|
962 | 962 | $field_value = $field_obj->get_default_value(); |
963 | 963 | } |
964 | - }else{ |
|
965 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
964 | + } else { |
|
965 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
966 | 966 | } |
967 | 967 | $this->_fields[$field_name] = $field_value; |
968 | - $this->_clear_cached_property( $field_name ); |
|
968 | + $this->_clear_cached_property($field_name); |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
@@ -981,8 +981,8 @@ discard block |
||
981 | 981 | * @return mixed |
982 | 982 | * @throws \EE_Error |
983 | 983 | */ |
984 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
985 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
984 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
985 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | |
@@ -1015,10 +1015,10 @@ discard block |
||
1015 | 1015 | * just null is returned (because that indicates that likely |
1016 | 1016 | * this field is nullable). |
1017 | 1017 | */ |
1018 | - public function get_DateTime_object( $field_name ) { |
|
1019 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
1018 | + public function get_DateTime_object($field_name) { |
|
1019 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
1020 | 1020 | |
1021 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
1021 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
1022 | 1022 | EE_Error::add_error( |
1023 | 1023 | sprintf( |
1024 | 1024 | __( |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | * @return void |
1051 | 1051 | * @throws \EE_Error |
1052 | 1052 | */ |
1053 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
1053 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
1054 | 1054 | echo $this->get_pretty($field_name, $extra_cache_ref); |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1064,8 +1064,8 @@ discard block |
||
1064 | 1064 | * @return void |
1065 | 1065 | * @throws \EE_Error |
1066 | 1066 | */ |
1067 | - public function f($field_name){ |
|
1068 | - $this->e($field_name,'form_input'); |
|
1067 | + public function f($field_name) { |
|
1068 | + $this->e($field_name, 'form_input'); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | |
@@ -1078,8 +1078,8 @@ discard block |
||
1078 | 1078 | * @return mixed |
1079 | 1079 | * @throws \EE_Error |
1080 | 1080 | */ |
1081 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
1082 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
1081 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
1082 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | |
@@ -1097,36 +1097,36 @@ discard block |
||
1097 | 1097 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
1098 | 1098 | * @throws \EE_Error |
1099 | 1099 | */ |
1100 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
1100 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
1101 | 1101 | |
1102 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1102 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1103 | 1103 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1104 | 1104 | |
1105 | 1105 | //validate field for datetime and returns field settings if valid. |
1106 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1106 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1107 | 1107 | |
1108 | 1108 | //clear cached property if either formats are not null. |
1109 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1110 | - $this->_clear_cached_property( $field_name ); |
|
1109 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1110 | + $this->_clear_cached_property($field_name); |
|
1111 | 1111 | //reset format properties because they are used in get() |
1112 | 1112 | $this->_dt_frmt = $in_dt_frmt; |
1113 | 1113 | $this->_tm_frmt = $in_tm_frmt; |
1114 | 1114 | } |
1115 | - if ( $echo ) { |
|
1116 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1115 | + if ($echo) { |
|
1116 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1117 | 1117 | } else { |
1118 | - $field->set_date_format( $in_dt_frmt ); |
|
1118 | + $field->set_date_format($in_dt_frmt); |
|
1119 | 1119 | } |
1120 | - if ( $echo ) { |
|
1121 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1120 | + if ($echo) { |
|
1121 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1122 | 1122 | } else { |
1123 | - $field->set_time_format( $in_tm_frmt ); |
|
1123 | + $field->set_time_format($in_tm_frmt); |
|
1124 | 1124 | } |
1125 | 1125 | //set timezone in field object |
1126 | - $field->set_timezone( $this->_timezone ); |
|
1126 | + $field->set_timezone($this->_timezone); |
|
1127 | 1127 | |
1128 | 1128 | //set the output returned |
1129 | - switch ( $date_or_time ) { |
|
1129 | + switch ($date_or_time) { |
|
1130 | 1130 | |
1131 | 1131 | case 'D' : |
1132 | 1132 | $field->set_date_time_output('date'); |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | |
1144 | - if ( $echo ) { |
|
1145 | - $this->e( $field_name, $date_or_time ); |
|
1144 | + if ($echo) { |
|
1145 | + $this->e($field_name, $date_or_time); |
|
1146 | 1146 | return ''; |
1147 | 1147 | } |
1148 | - return $this->get( $field_name, $date_or_time ); |
|
1148 | + return $this->get($field_name, $date_or_time); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1158,8 +1158,8 @@ discard block |
||
1158 | 1158 | * @return string datetime value formatted |
1159 | 1159 | * @throws \EE_Error |
1160 | 1160 | */ |
1161 | - public function get_date( $field_name, $format = NULL ) { |
|
1162 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1161 | + public function get_date($field_name, $format = NULL) { |
|
1162 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | |
@@ -1169,8 +1169,8 @@ discard block |
||
1169 | 1169 | * @param null $format |
1170 | 1170 | * @throws \EE_Error |
1171 | 1171 | */ |
1172 | - public function e_date( $field_name, $format = NULL ) { |
|
1173 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1172 | + public function e_date($field_name, $format = NULL) { |
|
1173 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | |
@@ -1183,8 +1183,8 @@ discard block |
||
1183 | 1183 | * @return string datetime value formatted |
1184 | 1184 | * @throws \EE_Error |
1185 | 1185 | */ |
1186 | - public function get_time( $field_name, $format = NULL ) { |
|
1187 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1186 | + public function get_time($field_name, $format = NULL) { |
|
1187 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
@@ -1194,8 +1194,8 @@ discard block |
||
1194 | 1194 | * @param null $format |
1195 | 1195 | * @throws \EE_Error |
1196 | 1196 | */ |
1197 | - public function e_time( $field_name, $format = NULL ) { |
|
1198 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1197 | + public function e_time($field_name, $format = NULL) { |
|
1198 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | |
@@ -1209,8 +1209,8 @@ discard block |
||
1209 | 1209 | * @return string datetime value formatted |
1210 | 1210 | * @throws \EE_Error |
1211 | 1211 | */ |
1212 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1213 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1212 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1213 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | |
@@ -1221,8 +1221,8 @@ discard block |
||
1221 | 1221 | * @param null $tm_frmt |
1222 | 1222 | * @throws \EE_Error |
1223 | 1223 | */ |
1224 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1225 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1224 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1225 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | |
@@ -1236,11 +1236,11 @@ discard block |
||
1236 | 1236 | * @throws \EE_Error |
1237 | 1237 | * field name. |
1238 | 1238 | */ |
1239 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1240 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1239 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1240 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1241 | 1241 | return date_i18n( |
1242 | 1242 | $format, |
1243 | - EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) |
|
1243 | + EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone) |
|
1244 | 1244 | ); |
1245 | 1245 | } |
1246 | 1246 | |
@@ -1253,14 +1253,14 @@ discard block |
||
1253 | 1253 | * @throws EE_Error |
1254 | 1254 | * @return EE_Datetime_Field |
1255 | 1255 | */ |
1256 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1256 | + protected function _get_dtt_field_settings($field_name) { |
|
1257 | 1257 | $field = $this->get_model()->field_settings_for($field_name); |
1258 | 1258 | |
1259 | 1259 | //check if field is dtt |
1260 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1260 | + if ($field instanceof EE_Datetime_Field) { |
|
1261 | 1261 | return $field; |
1262 | 1262 | } else { |
1263 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1263 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1264 | 1264 | } |
1265 | 1265 | } |
1266 | 1266 | |
@@ -1281,8 +1281,8 @@ discard block |
||
1281 | 1281 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1282 | 1282 | * @throws \EE_Error |
1283 | 1283 | */ |
1284 | - protected function _set_time_for( $time, $fieldname ) { |
|
1285 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1284 | + protected function _set_time_for($time, $fieldname) { |
|
1285 | + $this->_set_date_time('T', $time, $fieldname); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | |
@@ -1295,8 +1295,8 @@ discard block |
||
1295 | 1295 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1296 | 1296 | * @throws \EE_Error |
1297 | 1297 | */ |
1298 | - protected function _set_date_for( $date, $fieldname ) { |
|
1299 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1298 | + protected function _set_date_for($date, $fieldname) { |
|
1299 | + $this->_set_date_time('D', $date, $fieldname); |
|
1300 | 1300 | } |
1301 | 1301 | |
1302 | 1302 | |
@@ -1310,26 +1310,26 @@ discard block |
||
1310 | 1310 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1311 | 1311 | * @throws \EE_Error |
1312 | 1312 | */ |
1313 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1314 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1315 | - $field->set_timezone( $this->_timezone ); |
|
1316 | - $field->set_date_format( $this->_dt_frmt ); |
|
1317 | - $field->set_time_format( $this->_tm_frmt ); |
|
1318 | - switch ( $what ) { |
|
1313 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1314 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1315 | + $field->set_timezone($this->_timezone); |
|
1316 | + $field->set_date_format($this->_dt_frmt); |
|
1317 | + $field->set_time_format($this->_tm_frmt); |
|
1318 | + switch ($what) { |
|
1319 | 1319 | case 'T' : |
1320 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time( |
|
1320 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( |
|
1321 | 1321 | $datetime_value, |
1322 | - $this->_fields[ $fieldname ] |
|
1322 | + $this->_fields[$fieldname] |
|
1323 | 1323 | ); |
1324 | 1324 | break; |
1325 | 1325 | case 'D' : |
1326 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date( |
|
1326 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( |
|
1327 | 1327 | $datetime_value, |
1328 | - $this->_fields[ $fieldname ] |
|
1328 | + $this->_fields[$fieldname] |
|
1329 | 1329 | ); |
1330 | 1330 | break; |
1331 | 1331 | case 'B' : |
1332 | - $this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value ); |
|
1332 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1333 | 1333 | break; |
1334 | 1334 | } |
1335 | 1335 | $this->_clear_cached_property($fieldname); |
@@ -1351,17 +1351,17 @@ discard block |
||
1351 | 1351 | * @throws EE_Error |
1352 | 1352 | * @return string timestamp |
1353 | 1353 | */ |
1354 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1354 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1355 | 1355 | $timezone = EEH_DTT_Helper::get_timezone(); |
1356 | - if ( $timezone === $this->_timezone ) { |
|
1356 | + if ($timezone === $this->_timezone) { |
|
1357 | 1357 | return ''; |
1358 | 1358 | } |
1359 | 1359 | $original_timezone = $this->_timezone; |
1360 | - $this->set_timezone( $timezone ); |
|
1360 | + $this->set_timezone($timezone); |
|
1361 | 1361 | |
1362 | 1362 | $fn = (array) $field_name; |
1363 | - $args = array_merge( $fn, (array) $args ); |
|
1364 | - if ( ! method_exists( $this, $callback ) ) { |
|
1363 | + $args = array_merge($fn, (array) $args); |
|
1364 | + if ( ! method_exists($this, $callback)) { |
|
1365 | 1365 | throw new EE_Error( |
1366 | 1366 | sprintf( |
1367 | 1367 | __( |
@@ -1373,9 +1373,9 @@ discard block |
||
1373 | 1373 | ); |
1374 | 1374 | } |
1375 | 1375 | $args = (array) $args; |
1376 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1376 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1377 | 1377 | |
1378 | - $this->set_timezone( $original_timezone ); |
|
1378 | + $this->set_timezone($original_timezone); |
|
1379 | 1379 | return $return; |
1380 | 1380 | } |
1381 | 1381 | |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | * @return boolean | int |
1390 | 1390 | * @throws \EE_Error |
1391 | 1391 | */ |
1392 | - public function delete(){ |
|
1392 | + public function delete() { |
|
1393 | 1393 | /** |
1394 | 1394 | * Called just before the `EE_Base_Class::_delete` method call. |
1395 | 1395 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | * |
1399 | 1399 | * @param EE_Base_Class $model_object about to be 'deleted' |
1400 | 1400 | */ |
1401 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1401 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1402 | 1402 | $result = $this->_delete(); |
1403 | 1403 | /** |
1404 | 1404 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | * @param EE_Base_Class $model_object that was just 'deleted' |
1409 | 1409 | * @param boolean $result |
1410 | 1410 | */ |
1411 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1411 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1412 | 1412 | return $result; |
1413 | 1413 | } |
1414 | 1414 | |
@@ -1434,22 +1434,22 @@ discard block |
||
1434 | 1434 | * @return bool | int |
1435 | 1435 | * @throws \EE_Error |
1436 | 1436 | */ |
1437 | - public function delete_permanently(){ |
|
1437 | + public function delete_permanently() { |
|
1438 | 1438 | /** |
1439 | 1439 | * Called just before HARD deleting a model object |
1440 | 1440 | * |
1441 | 1441 | * @param EE_Base_Class $model_object about to be 'deleted' |
1442 | 1442 | */ |
1443 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1444 | - $model=$this->get_model(); |
|
1445 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1443 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1444 | + $model = $this->get_model(); |
|
1445 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1446 | 1446 | $this->refresh_cache_of_related_objects(); |
1447 | 1447 | /** |
1448 | 1448 | * Called just after HARD deleting a model object |
1449 | 1449 | * @param EE_Base_Class $model_object that was just 'deleted' |
1450 | 1450 | * @param boolean $result |
1451 | 1451 | */ |
1452 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1452 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1453 | 1453 | return $result; |
1454 | 1454 | } |
1455 | 1455 | |
@@ -1462,18 +1462,18 @@ discard block |
||
1462 | 1462 | * @throws \EE_Error |
1463 | 1463 | */ |
1464 | 1464 | public function refresh_cache_of_related_objects() { |
1465 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1466 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1467 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1468 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1465 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1466 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1467 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1468 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1469 | 1469 | //this relation only stores a single model object, not an array |
1470 | 1470 | //but let's make it consistent |
1471 | - $related_objects = array( $related_objects ); |
|
1471 | + $related_objects = array($related_objects); |
|
1472 | 1472 | } |
1473 | - foreach( $related_objects as $related_object ) { |
|
1473 | + foreach ($related_objects as $related_object) { |
|
1474 | 1474 | //only refresh their cache if they're in memory |
1475 | - if( $related_object instanceof EE_Base_Class ) { |
|
1476 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1475 | + if ($related_object instanceof EE_Base_Class) { |
|
1476 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | } |
@@ -1493,17 +1493,17 @@ discard block |
||
1493 | 1493 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1494 | 1494 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1495 | 1495 | */ |
1496 | - public function save($set_cols_n_values=array()) { |
|
1496 | + public function save($set_cols_n_values = array()) { |
|
1497 | 1497 | /** |
1498 | 1498 | * Filters the fields we're about to save on the model object |
1499 | 1499 | * |
1500 | 1500 | * @param array $set_cols_n_values |
1501 | 1501 | * @param EE_Base_Class $model_object |
1502 | 1502 | */ |
1503 | - $set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1503 | + $set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1504 | 1504 | //set attributes as provided in $set_cols_n_values |
1505 | - foreach($set_cols_n_values as $column=>$value){ |
|
1506 | - $this->set($column,$value); |
|
1505 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1506 | + $this->set($column, $value); |
|
1507 | 1507 | } |
1508 | 1508 | /** |
1509 | 1509 | * Saving a model object. |
@@ -1511,8 +1511,8 @@ discard block |
||
1511 | 1511 | * Before we perform a save, this action is fired. |
1512 | 1512 | * @param EE_Base_Class $model_object the model object about to be saved. |
1513 | 1513 | */ |
1514 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1515 | - if( ! $this->allow_persist() ) { |
|
1514 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1515 | + if ( ! $this->allow_persist()) { |
|
1516 | 1516 | return 0; |
1517 | 1517 | } |
1518 | 1518 | //now get current attribute values |
@@ -1522,61 +1522,61 @@ discard block |
||
1522 | 1522 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1523 | 1523 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1524 | 1524 | //does this model have an autoincrement PK? |
1525 | - if($this->get_model()->has_primary_key_field()){ |
|
1526 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1525 | + if ($this->get_model()->has_primary_key_field()) { |
|
1526 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1527 | 1527 | //ok check if it's set, if so: update; if not, insert |
1528 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1529 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1528 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1529 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1530 | 1530 | } else { |
1531 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1532 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1533 | - if($results){ |
|
1531 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1532 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1533 | + if ($results) { |
|
1534 | 1534 | //if successful, set the primary key |
1535 | 1535 | //but don't use the normal SET method, because it will check if |
1536 | 1536 | //an item with the same ID exists in the mapper & db, then |
1537 | 1537 | //will find it in the db (because we just added it) and THAT object |
1538 | 1538 | //will get added to the mapper before we can add this one! |
1539 | 1539 | //but if we just avoid using the SET method, all that headache can be avoided |
1540 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1540 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1541 | 1541 | $this->_fields[$pk_field_name] = $results; |
1542 | 1542 | $this->_clear_cached_property($pk_field_name); |
1543 | - $this->get_model()->add_to_entity_map( $this ); |
|
1543 | + $this->get_model()->add_to_entity_map($this); |
|
1544 | 1544 | $this->_update_cached_related_model_objs_fks(); |
1545 | 1545 | } |
1546 | 1546 | } |
1547 | - }else{//PK is NOT auto-increment |
|
1547 | + } else {//PK is NOT auto-increment |
|
1548 | 1548 | //so check if one like it already exists in the db |
1549 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1550 | - if( WP_DEBUG && ! $this->in_entity_map() ){ |
|
1549 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1550 | + if (WP_DEBUG && ! $this->in_entity_map()) { |
|
1551 | 1551 | throw new EE_Error( |
1552 | 1552 | sprintf( |
1553 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1553 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1554 | 1554 | get_class($this), |
1555 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1556 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1555 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1556 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1557 | 1557 | '<br />' |
1558 | 1558 | ) |
1559 | 1559 | ); |
1560 | 1560 | } |
1561 | 1561 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1562 | - }else{ |
|
1562 | + } else { |
|
1563 | 1563 | $results = $this->get_model()->insert($save_cols_n_values); |
1564 | 1564 | $this->_update_cached_related_model_objs_fks(); |
1565 | 1565 | } |
1566 | 1566 | } |
1567 | - }else{//there is NO primary key |
|
1567 | + } else {//there is NO primary key |
|
1568 | 1568 | $already_in_db = false; |
1569 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1569 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1570 | 1570 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1571 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1571 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1572 | 1572 | $already_in_db = true; |
1573 | 1573 | } |
1574 | 1574 | } |
1575 | - if( $already_in_db ){ |
|
1576 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1577 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1578 | - }else{ |
|
1579 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1575 | + if ($already_in_db) { |
|
1576 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1577 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1578 | + } else { |
|
1579 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1580 | 1580 | } |
1581 | 1581 | } |
1582 | 1582 | //restore the old assumption about values being prepared by the model object |
@@ -1589,7 +1589,7 @@ discard block |
||
1589 | 1589 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1590 | 1590 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1591 | 1591 | */ |
1592 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1592 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1593 | 1593 | return $results; |
1594 | 1594 | } |
1595 | 1595 | |
@@ -1604,15 +1604,15 @@ discard block |
||
1604 | 1604 | * @return void |
1605 | 1605 | * @throws \EE_Error |
1606 | 1606 | */ |
1607 | - protected function _update_cached_related_model_objs_fks(){ |
|
1608 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1609 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1610 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1607 | + protected function _update_cached_related_model_objs_fks() { |
|
1608 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1609 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1610 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1611 | 1611 | $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( |
1612 | 1612 | $this->get_model()->get_this_model_name() |
1613 | 1613 | ); |
1614 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1615 | - if( $related_model_obj_in_cache->ID() ){ |
|
1614 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1615 | + if ($related_model_obj_in_cache->ID()) { |
|
1616 | 1616 | $related_model_obj_in_cache->save(); |
1617 | 1617 | } |
1618 | 1618 | } |
@@ -1633,21 +1633,21 @@ discard block |
||
1633 | 1633 | * @return int ID of new model object on save; 0 on failure+ |
1634 | 1634 | * @throws \EE_Error |
1635 | 1635 | */ |
1636 | - public function save_new_cached_related_model_objs(){ |
|
1636 | + public function save_new_cached_related_model_objs() { |
|
1637 | 1637 | //make sure this has been saved |
1638 | - if( ! $this->ID()){ |
|
1638 | + if ( ! $this->ID()) { |
|
1639 | 1639 | $id = $this->save(); |
1640 | - }else{ |
|
1640 | + } else { |
|
1641 | 1641 | $id = $this->ID(); |
1642 | 1642 | } |
1643 | 1643 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1644 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1644 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1645 | 1645 | |
1646 | 1646 | |
1647 | - if($this->_model_relations[$relationName]){ |
|
1647 | + if ($this->_model_relations[$relationName]) { |
|
1648 | 1648 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1649 | 1649 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1650 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1650 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1651 | 1651 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1652 | 1652 | //but ONLY if it DOES NOT exist in the DB |
1653 | 1653 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1656,8 +1656,8 @@ discard block |
||
1656 | 1656 | $this->_add_relation_to($related_model_obj, $relationName); |
1657 | 1657 | $related_model_obj->save_new_cached_related_model_objs(); |
1658 | 1658 | // } |
1659 | - }else{ |
|
1660 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1659 | + } else { |
|
1660 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1661 | 1661 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1662 | 1662 | //but ONLY if it DOES NOT exist in the DB |
1663 | 1663 | // if( ! $related_model_obj->ID()){ |
@@ -1678,8 +1678,8 @@ discard block |
||
1678 | 1678 | * @return \EEM_Base | \EEM_CPT_Base |
1679 | 1679 | */ |
1680 | 1680 | public function get_model() { |
1681 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1682 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1681 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1682 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | |
@@ -1690,10 +1690,10 @@ discard block |
||
1690 | 1690 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1691 | 1691 | * @throws \EE_Error |
1692 | 1692 | */ |
1693 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1693 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1694 | 1694 | //TODO: will not work for Term_Relationships because they have no PK! |
1695 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1696 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1695 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1696 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1697 | 1697 | $id = $props_n_values[$primary_id_ref]; |
1698 | 1698 | return self::_get_model($classname)->get_from_entity_map($id); |
1699 | 1699 | } |
@@ -1714,38 +1714,38 @@ discard block |
||
1714 | 1714 | * @return mixed (EE_Base_Class|bool) |
1715 | 1715 | * @throws \EE_Error |
1716 | 1716 | */ |
1717 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1717 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1718 | 1718 | $existing = null; |
1719 | - if ( self::_get_model( $classname )->has_primary_key_field() ) { |
|
1720 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1719 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1720 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1721 | 1721 | if ( |
1722 | - array_key_exists( $primary_id_ref, $props_n_values ) |
|
1723 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1722 | + array_key_exists($primary_id_ref, $props_n_values) |
|
1723 | + && ! empty($props_n_values[$primary_id_ref]) |
|
1724 | 1724 | ) { |
1725 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1726 | - $props_n_values[ $primary_id_ref ] |
|
1725 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1726 | + $props_n_values[$primary_id_ref] |
|
1727 | 1727 | ); |
1728 | 1728 | } |
1729 | - } elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) { |
|
1729 | + } elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1730 | 1730 | //no primary key on this model, but there's still a matching item in the DB |
1731 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1732 | - self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values ) |
|
1731 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1732 | + self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values) |
|
1733 | 1733 | ); |
1734 | 1734 | } |
1735 | - if ( $existing ) { |
|
1735 | + if ($existing) { |
|
1736 | 1736 | |
1737 | 1737 | //set date formats if present before setting values |
1738 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1739 | - $existing->set_date_format( $date_formats[0] ); |
|
1740 | - $existing->set_time_format( $date_formats[1] ); |
|
1738 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1739 | + $existing->set_date_format($date_formats[0]); |
|
1740 | + $existing->set_time_format($date_formats[1]); |
|
1741 | 1741 | } else { |
1742 | 1742 | //set default formats for date and time |
1743 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1744 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1743 | + $existing->set_date_format(get_option('date_format')); |
|
1744 | + $existing->set_time_format(get_option('time_format')); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1748 | - $existing->set( $property, $field_value ); |
|
1747 | + foreach ($props_n_values as $property => $field_value) { |
|
1748 | + $existing->set($property, $field_value); |
|
1749 | 1749 | } |
1750 | 1750 | return $existing; |
1751 | 1751 | } else { |
@@ -1763,9 +1763,9 @@ discard block |
||
1763 | 1763 | * @throws EE_Error |
1764 | 1764 | * @return EEM_Base |
1765 | 1765 | */ |
1766 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1766 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1767 | 1767 | //find model for this class |
1768 | - if( ! $classname ){ |
|
1768 | + if ( ! $classname) { |
|
1769 | 1769 | throw new EE_Error( |
1770 | 1770 | sprintf( |
1771 | 1771 | __( |
@@ -1776,8 +1776,8 @@ discard block |
||
1776 | 1776 | ) |
1777 | 1777 | ); |
1778 | 1778 | } |
1779 | - $modelName=self::_get_model_classname($classname); |
|
1780 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1779 | + $modelName = self::_get_model_classname($classname); |
|
1780 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | |
@@ -1788,10 +1788,10 @@ discard block |
||
1788 | 1788 | * @param null $timezone |
1789 | 1789 | * @return EEM_Base |
1790 | 1790 | */ |
1791 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1792 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1793 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1794 | - $model->set_timezone( $timezone ); |
|
1791 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1792 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1793 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1794 | + $model->set_timezone($timezone); |
|
1795 | 1795 | return $model; |
1796 | 1796 | } |
1797 | 1797 | |
@@ -1803,10 +1803,10 @@ discard block |
||
1803 | 1803 | * @param null $model_name |
1804 | 1804 | * @return string like EEM_Attendee |
1805 | 1805 | */ |
1806 | - private static function _get_model_classname( $model_name = null){ |
|
1807 | - if(strpos($model_name,"EE_")===0){ |
|
1808 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1809 | - }else{ |
|
1806 | + private static function _get_model_classname($model_name = null) { |
|
1807 | + if (strpos($model_name, "EE_") === 0) { |
|
1808 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1809 | + } else { |
|
1810 | 1810 | $model_classname = "EEM_".$model_name; |
1811 | 1811 | } |
1812 | 1812 | return $model_classname; |
@@ -1820,16 +1820,16 @@ discard block |
||
1820 | 1820 | * @throws EE_Error |
1821 | 1821 | * @return string |
1822 | 1822 | */ |
1823 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1824 | - if( ! $classname){ |
|
1823 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1824 | + if ( ! $classname) { |
|
1825 | 1825 | throw new EE_Error( |
1826 | 1826 | sprintf( |
1827 | - __( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ), |
|
1827 | + __("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), |
|
1828 | 1828 | $classname |
1829 | 1829 | ) |
1830 | 1830 | ); |
1831 | 1831 | } |
1832 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1832 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | 1835 | |
@@ -1843,12 +1843,12 @@ discard block |
||
1843 | 1843 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1844 | 1844 | * @throws \EE_Error |
1845 | 1845 | */ |
1846 | - public function ID(){ |
|
1846 | + public function ID() { |
|
1847 | 1847 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1848 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1849 | - return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
|
1850 | - }else{ |
|
1851 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1848 | + if ($this->get_model()->has_primary_key_field()) { |
|
1849 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1850 | + } else { |
|
1851 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1852 | 1852 | } |
1853 | 1853 | } |
1854 | 1854 | |
@@ -1866,38 +1866,38 @@ discard block |
||
1866 | 1866 | * @throws EE_Error |
1867 | 1867 | * @return EE_Base_Class the object the relation was added to |
1868 | 1868 | */ |
1869 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1869 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1870 | 1870 | //if this thing exists in the DB, save the relation to the DB |
1871 | - if( $this->ID() ){ |
|
1872 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1871 | + if ($this->ID()) { |
|
1872 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1873 | 1873 | //clear cache so future get_many_related and get_first_related() return new results. |
1874 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1875 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1876 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1874 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1875 | + if ($otherObject instanceof EE_Base_Class) { |
|
1876 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1877 | 1877 | } |
1878 | 1878 | } else { |
1879 | 1879 | //this thing doesn't exist in the DB, so just cache it |
1880 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1881 | - throw new EE_Error( sprintf( |
|
1882 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1880 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1881 | + throw new EE_Error(sprintf( |
|
1882 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1883 | 1883 | $otherObjectModelObjectOrID, |
1884 | - get_class( $this ) |
|
1884 | + get_class($this) |
|
1885 | 1885 | )); |
1886 | 1886 | } else { |
1887 | 1887 | $otherObject = $otherObjectModelObjectOrID; |
1888 | 1888 | } |
1889 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1889 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1890 | 1890 | } |
1891 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1891 | + if ($otherObject instanceof EE_Base_Class) { |
|
1892 | 1892 | //fix the reciprocal relation too |
1893 | - if( $otherObject->ID() ) { |
|
1893 | + if ($otherObject->ID()) { |
|
1894 | 1894 | //its saved so assumed relations exist in the DB, so we can just |
1895 | 1895 | //clear the cache so future queries use the updated info in the DB |
1896 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1896 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1897 | 1897 | } else { |
1898 | 1898 | |
1899 | 1899 | //it's not saved, so it caches relations like this |
1900 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1900 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1901 | 1901 | } |
1902 | 1902 | } |
1903 | 1903 | return $otherObject; |
@@ -1921,17 +1921,17 @@ discard block |
||
1921 | 1921 | * @return EE_Base_Class the relation was removed from |
1922 | 1922 | * @throws \EE_Error |
1923 | 1923 | */ |
1924 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1925 | - if ( $this->ID() ) { |
|
1924 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1925 | + if ($this->ID()) { |
|
1926 | 1926 | //if this exists in the DB, save the relation change to the DB too |
1927 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1928 | - $this->clear_cache( $relationName, $otherObject ); |
|
1927 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1928 | + $this->clear_cache($relationName, $otherObject); |
|
1929 | 1929 | } else { |
1930 | 1930 | //this doesn't exist in the DB, just remove it from the cache |
1931 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1931 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1932 | 1932 | } |
1933 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1934 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1933 | + if ($otherObject instanceof EE_Base_Class) { |
|
1934 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1935 | 1935 | } |
1936 | 1936 | return $otherObject; |
1937 | 1937 | } |
@@ -1946,18 +1946,18 @@ discard block |
||
1946 | 1946 | * @return EE_Base_Class |
1947 | 1947 | * @throws \EE_Error |
1948 | 1948 | */ |
1949 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1950 | - if ( $this->ID() ) { |
|
1949 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1950 | + if ($this->ID()) { |
|
1951 | 1951 | //if this exists in the DB, save the relation change to the DB too |
1952 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1953 | - $this->clear_cache( $relationName, null, true ); |
|
1952 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1953 | + $this->clear_cache($relationName, null, true); |
|
1954 | 1954 | } else { |
1955 | 1955 | //this doesn't exist in the DB, just remove it from the cache |
1956 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1956 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1957 | 1957 | } |
1958 | - if( is_array( $otherObjects ) ) { |
|
1959 | - foreach ( $otherObjects as $otherObject ) { |
|
1960 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1958 | + if (is_array($otherObjects)) { |
|
1959 | + foreach ($otherObjects as $otherObject) { |
|
1960 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1961 | 1961 | } |
1962 | 1962 | } |
1963 | 1963 | return $otherObjects; |
@@ -1977,27 +1977,27 @@ discard block |
||
1977 | 1977 | * @throws \EE_Error |
1978 | 1978 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1979 | 1979 | */ |
1980 | - public function get_many_related($relationName,$query_params = array()){ |
|
1981 | - if($this->ID()){ |
|
1980 | + public function get_many_related($relationName, $query_params = array()) { |
|
1981 | + if ($this->ID()) { |
|
1982 | 1982 | //this exists in the DB, so get the related things from either the cache or the DB |
1983 | 1983 | //if there are query parameters, forget about caching the related model objects. |
1984 | - if( $query_params ){ |
|
1984 | + if ($query_params) { |
|
1985 | 1985 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1986 | - }else{ |
|
1986 | + } else { |
|
1987 | 1987 | //did we already cache the result of this query? |
1988 | 1988 | $cached_results = $this->get_all_from_cache($relationName); |
1989 | - if ( ! $cached_results ){ |
|
1989 | + if ( ! $cached_results) { |
|
1990 | 1990 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1991 | 1991 | //if no query parameters were passed, then we got all the related model objects |
1992 | 1992 | //for that relation. We can cache them then. |
1993 | - foreach($related_model_objects as $related_model_object){ |
|
1993 | + foreach ($related_model_objects as $related_model_object) { |
|
1994 | 1994 | $this->cache($relationName, $related_model_object); |
1995 | 1995 | } |
1996 | - }else{ |
|
1996 | + } else { |
|
1997 | 1997 | $related_model_objects = $cached_results; |
1998 | 1998 | } |
1999 | 1999 | } |
2000 | - }else{ |
|
2000 | + } else { |
|
2001 | 2001 | //this doesn't exist in the DB, so just get the related things from the cache |
2002 | 2002 | $related_model_objects = $this->get_all_from_cache($relationName); |
2003 | 2003 | } |
@@ -2015,8 +2015,8 @@ discard block |
||
2015 | 2015 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
2016 | 2016 | * @return int |
2017 | 2017 | */ |
2018 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
2019 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
2018 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
2019 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
2020 | 2020 | } |
2021 | 2021 | |
2022 | 2022 | |
@@ -2030,7 +2030,7 @@ discard block |
||
2030 | 2030 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
2031 | 2031 | * @return int |
2032 | 2032 | */ |
2033 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
2033 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
2034 | 2034 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
2035 | 2035 | } |
2036 | 2036 | |
@@ -2044,33 +2044,33 @@ discard block |
||
2044 | 2044 | * @return EE_Base_Class (not an array, a single object) |
2045 | 2045 | * @throws \EE_Error |
2046 | 2046 | */ |
2047 | - public function get_first_related($relationName,$query_params = array()){ |
|
2048 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
2047 | + public function get_first_related($relationName, $query_params = array()) { |
|
2048 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
2049 | 2049 | |
2050 | 2050 | //if they've provided some query parameters, don't bother trying to cache the result |
2051 | 2051 | //also make sure we're not caching the result of get_first_related |
2052 | 2052 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2053 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2054 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2055 | - }else{ |
|
2053 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2054 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2055 | + } else { |
|
2056 | 2056 | //first, check if we've already cached the result of this query |
2057 | 2057 | $cached_result = $this->get_one_from_cache($relationName); |
2058 | - if ( ! $cached_result ){ |
|
2058 | + if ( ! $cached_result) { |
|
2059 | 2059 | |
2060 | 2060 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2061 | - $this->cache($relationName,$related_model_object); |
|
2062 | - }else{ |
|
2061 | + $this->cache($relationName, $related_model_object); |
|
2062 | + } else { |
|
2063 | 2063 | $related_model_object = $cached_result; |
2064 | 2064 | } |
2065 | 2065 | } |
2066 | - }else{ |
|
2066 | + } else { |
|
2067 | 2067 | $related_model_object = null; |
2068 | 2068 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2069 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2070 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2069 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2070 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2071 | 2071 | } |
2072 | 2072 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
2073 | - if( ! $related_model_object){ |
|
2073 | + if ( ! $related_model_object) { |
|
2074 | 2074 | $related_model_object = $this->get_one_from_cache($relationName); |
2075 | 2075 | } |
2076 | 2076 | |
@@ -2092,12 +2092,12 @@ discard block |
||
2092 | 2092 | * @return int how many deleted |
2093 | 2093 | * @throws \EE_Error |
2094 | 2094 | */ |
2095 | - public function delete_related($relationName,$query_params = array()){ |
|
2096 | - if($this->ID()){ |
|
2097 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2098 | - }else{ |
|
2095 | + public function delete_related($relationName, $query_params = array()) { |
|
2096 | + if ($this->ID()) { |
|
2097 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2098 | + } else { |
|
2099 | 2099 | $count = count($this->get_all_from_cache($relationName)); |
2100 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2100 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2101 | 2101 | } |
2102 | 2102 | return $count; |
2103 | 2103 | } |
@@ -2116,13 +2116,13 @@ discard block |
||
2116 | 2116 | * @return int how many deleted (including those soft deleted) |
2117 | 2117 | * @throws \EE_Error |
2118 | 2118 | */ |
2119 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
2120 | - if($this->ID()){ |
|
2121 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2122 | - }else{ |
|
2119 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
2120 | + if ($this->ID()) { |
|
2121 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2122 | + } else { |
|
2123 | 2123 | $count = count($this->get_all_from_cache($relationName)); |
2124 | 2124 | } |
2125 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2125 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2126 | 2126 | return $count; |
2127 | 2127 | } |
2128 | 2128 | |
@@ -2138,7 +2138,7 @@ discard block |
||
2138 | 2138 | * @param string $field_name property to check |
2139 | 2139 | * @return bool TRUE if existing,FALSE if not. |
2140 | 2140 | */ |
2141 | - public function is_set( $field_name ) { |
|
2141 | + public function is_set($field_name) { |
|
2142 | 2142 | return isset($this->_fields[$field_name]); |
2143 | 2143 | } |
2144 | 2144 | |
@@ -2150,11 +2150,11 @@ discard block |
||
2150 | 2150 | * @throws EE_Error |
2151 | 2151 | * @return bool TRUE if existing, throw EE_Error if not. |
2152 | 2152 | */ |
2153 | - protected function _property_exists( $properties ) { |
|
2153 | + protected function _property_exists($properties) { |
|
2154 | 2154 | |
2155 | - foreach ( (array) $properties as $property_name ) { |
|
2155 | + foreach ((array) $properties as $property_name) { |
|
2156 | 2156 | //first make sure this property exists |
2157 | - if ( ! $this->_fields[ $property_name ] ) { |
|
2157 | + if ( ! $this->_fields[$property_name]) { |
|
2158 | 2158 | throw new EE_Error( |
2159 | 2159 | sprintf( |
2160 | 2160 | __( |
@@ -2182,7 +2182,7 @@ discard block |
||
2182 | 2182 | $fields = $this->get_model()->field_settings(FALSE); |
2183 | 2183 | $properties = array(); |
2184 | 2184 | //remove prepended underscore |
2185 | - foreach ( $fields as $field_name => $settings ) { |
|
2185 | + foreach ($fields as $field_name => $settings) { |
|
2186 | 2186 | $properties[$field_name] = $this->get($field_name); |
2187 | 2187 | } |
2188 | 2188 | return $properties; |
@@ -2212,10 +2212,10 @@ discard block |
||
2212 | 2212 | * @throws EE_Error |
2213 | 2213 | * @return mixed whatever the plugin which calls add_filter decides |
2214 | 2214 | */ |
2215 | - public function __call($methodName,$args){ |
|
2216 | - $className=get_class($this); |
|
2217 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2218 | - if ( ! has_filter( $tagName ) ) { |
|
2215 | + public function __call($methodName, $args) { |
|
2216 | + $className = get_class($this); |
|
2217 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2218 | + if ( ! has_filter($tagName)) { |
|
2219 | 2219 | throw new EE_Error( |
2220 | 2220 | sprintf( |
2221 | 2221 | __( |
@@ -2228,7 +2228,7 @@ discard block |
||
2228 | 2228 | ) |
2229 | 2229 | ); |
2230 | 2230 | } |
2231 | - return apply_filters($tagName,null,$this,$args); |
|
2231 | + return apply_filters($tagName, null, $this, $args); |
|
2232 | 2232 | } |
2233 | 2233 | |
2234 | 2234 | |
@@ -2244,7 +2244,7 @@ discard block |
||
2244 | 2244 | * @throws \EE_Error |
2245 | 2245 | * NOTE: if the values haven't changed, returns 0 |
2246 | 2246 | */ |
2247 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2247 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2248 | 2248 | $query_params = array( |
2249 | 2249 | array( |
2250 | 2250 | 'EXM_key' => $meta_key, |
@@ -2252,17 +2252,17 @@ discard block |
||
2252 | 2252 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2253 | 2253 | ) |
2254 | 2254 | ); |
2255 | - if ( $previous_value !== null ) { |
|
2255 | + if ($previous_value !== null) { |
|
2256 | 2256 | $query_params[0]['EXM_value'] = $meta_value; |
2257 | 2257 | } |
2258 | - $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params ); |
|
2259 | - if ( ! $existing_rows_like_that ) { |
|
2260 | - return $this->add_extra_meta( $meta_key, $meta_value ); |
|
2258 | + $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
|
2259 | + if ( ! $existing_rows_like_that) { |
|
2260 | + return $this->add_extra_meta($meta_key, $meta_value); |
|
2261 | 2261 | } else { |
2262 | - foreach ( $existing_rows_like_that as $existing_row ) { |
|
2263 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2262 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2263 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2264 | 2264 | } |
2265 | - return count( $existing_rows_like_that ); |
|
2265 | + return count($existing_rows_like_that); |
|
2266 | 2266 | } |
2267 | 2267 | } |
2268 | 2268 | |
@@ -2279,8 +2279,8 @@ discard block |
||
2279 | 2279 | * @return boolean |
2280 | 2280 | * @throws \EE_Error |
2281 | 2281 | */ |
2282 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2283 | - if ( $unique ) { |
|
2282 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2283 | + if ($unique) { |
|
2284 | 2284 | $existing_extra_meta = EEM_Extra_Meta::instance()->get_one( |
2285 | 2285 | array( |
2286 | 2286 | array( |
@@ -2290,7 +2290,7 @@ discard block |
||
2290 | 2290 | ) |
2291 | 2291 | ) |
2292 | 2292 | ); |
2293 | - if ( $existing_extra_meta ) { |
|
2293 | + if ($existing_extra_meta) { |
|
2294 | 2294 | return false; |
2295 | 2295 | } |
2296 | 2296 | } |
@@ -2317,7 +2317,7 @@ discard block |
||
2317 | 2317 | * @return int number of extra meta rows deleted |
2318 | 2318 | * @throws \EE_Error |
2319 | 2319 | */ |
2320 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2320 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2321 | 2321 | $query_params = array( |
2322 | 2322 | array( |
2323 | 2323 | 'EXM_key' => $meta_key, |
@@ -2325,10 +2325,10 @@ discard block |
||
2325 | 2325 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2326 | 2326 | ) |
2327 | 2327 | ); |
2328 | - if ( $meta_value !== null ) { |
|
2328 | + if ($meta_value !== null) { |
|
2329 | 2329 | $query_params[0]['EXM_value'] = $meta_value; |
2330 | 2330 | } |
2331 | - return EEM_Extra_Meta::instance()->delete( $query_params ); |
|
2331 | + return EEM_Extra_Meta::instance()->delete($query_params); |
|
2332 | 2332 | } |
2333 | 2333 | |
2334 | 2334 | |
@@ -2344,25 +2344,25 @@ discard block |
||
2344 | 2344 | * @return mixed single value if $single; array if ! $single |
2345 | 2345 | * @throws \EE_Error |
2346 | 2346 | */ |
2347 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2348 | - if($single){ |
|
2349 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2350 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2347 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2348 | + if ($single) { |
|
2349 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2350 | + if ($result instanceof EE_Extra_Meta) { |
|
2351 | 2351 | return $result->value(); |
2352 | - }else{ |
|
2352 | + } else { |
|
2353 | 2353 | return $default; |
2354 | 2354 | } |
2355 | - }else{ |
|
2356 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2357 | - if($results){ |
|
2355 | + } else { |
|
2356 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2357 | + if ($results) { |
|
2358 | 2358 | $values = array(); |
2359 | - foreach($results as $result){ |
|
2360 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2359 | + foreach ($results as $result) { |
|
2360 | + if ($result instanceof EE_Extra_Meta) { |
|
2361 | 2361 | $values[$result->ID()] = $result->value(); |
2362 | 2362 | } |
2363 | 2363 | } |
2364 | 2364 | return $values; |
2365 | - }else{ |
|
2365 | + } else { |
|
2366 | 2366 | return $default; |
2367 | 2367 | } |
2368 | 2368 | } |
@@ -2384,20 +2384,20 @@ discard block |
||
2384 | 2384 | * @return array |
2385 | 2385 | * @throws \EE_Error |
2386 | 2386 | */ |
2387 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2387 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2388 | 2388 | $return_array = array(); |
2389 | - if($one_of_each_key){ |
|
2389 | + if ($one_of_each_key) { |
|
2390 | 2390 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2391 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2392 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2391 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2392 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2393 | 2393 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2394 | 2394 | } |
2395 | 2395 | } |
2396 | - }else{ |
|
2396 | + } else { |
|
2397 | 2397 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2398 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2399 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2400 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2398 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2399 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2400 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2401 | 2401 | $return_array[$extra_meta_obj->key()] = array(); |
2402 | 2402 | } |
2403 | 2403 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2415,19 +2415,19 @@ discard block |
||
2415 | 2415 | * @return string |
2416 | 2416 | * @throws \EE_Error |
2417 | 2417 | */ |
2418 | - public function name(){ |
|
2418 | + public function name() { |
|
2419 | 2419 | //find a field that's not a text field |
2420 | 2420 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2421 | - if($field_we_can_use){ |
|
2421 | + if ($field_we_can_use) { |
|
2422 | 2422 | return $this->get($field_we_can_use->get_name()); |
2423 | - }else{ |
|
2423 | + } else { |
|
2424 | 2424 | $first_few_properties = $this->model_field_array(); |
2425 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2425 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2426 | 2426 | $name_parts = array(); |
2427 | - foreach( $first_few_properties as $name=> $value ){ |
|
2427 | + foreach ($first_few_properties as $name=> $value) { |
|
2428 | 2428 | $name_parts[] = "$name:$value"; |
2429 | 2429 | } |
2430 | - return implode(",",$name_parts); |
|
2430 | + return implode(",", $name_parts); |
|
2431 | 2431 | } |
2432 | 2432 | } |
2433 | 2433 | |
@@ -2440,11 +2440,11 @@ discard block |
||
2440 | 2440 | * @return boolean |
2441 | 2441 | * @throws \EE_Error |
2442 | 2442 | */ |
2443 | - public function in_entity_map(){ |
|
2444 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2443 | + public function in_entity_map() { |
|
2444 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2445 | 2445 | //well, if we looked, did we find it in the entity map? |
2446 | 2446 | return TRUE; |
2447 | - }else{ |
|
2447 | + } else { |
|
2448 | 2448 | return FALSE; |
2449 | 2449 | } |
2450 | 2450 | } |
@@ -2455,21 +2455,21 @@ discard block |
||
2455 | 2455 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2456 | 2456 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2457 | 2457 | */ |
2458 | - public function refresh_from_db(){ |
|
2459 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2460 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2461 | - }else{ |
|
2458 | + public function refresh_from_db() { |
|
2459 | + if ($this->ID() && $this->in_entity_map()) { |
|
2460 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2461 | + } else { |
|
2462 | 2462 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2463 | 2463 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2464 | 2464 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2465 | 2465 | //absolutely nothing in it for this ID |
2466 | - if( WP_DEBUG ) { |
|
2466 | + if (WP_DEBUG) { |
|
2467 | 2467 | throw new EE_Error( |
2468 | 2468 | sprintf( |
2469 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2469 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2470 | 2470 | $this->ID(), |
2471 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2472 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2471 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2472 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2473 | 2473 | ) |
2474 | 2474 | ); |
2475 | 2475 | } |
@@ -2483,11 +2483,11 @@ discard block |
||
2483 | 2483 | * (probably a bad assumption they have made, oh well) |
2484 | 2484 | * @return string |
2485 | 2485 | */ |
2486 | - public function __toString(){ |
|
2486 | + public function __toString() { |
|
2487 | 2487 | try { |
2488 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2489 | - } catch ( Exception $e ) { |
|
2490 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
2488 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2489 | + } catch (Exception $e) { |
|
2490 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
2491 | 2491 | return ''; |
2492 | 2492 | } |
2493 | 2493 | } |
@@ -2523,16 +2523,16 @@ discard block |
||
2523 | 2523 | * @throws \EE_Error |
2524 | 2524 | */ |
2525 | 2525 | public function __sleep() { |
2526 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2527 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2528 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2529 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2530 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2531 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2526 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2527 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2528 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2529 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2530 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2531 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2532 | 2532 | } |
2533 | 2533 | } |
2534 | 2534 | } |
2535 | - return array_keys( get_object_vars( $this ) ); |
|
2535 | + return array_keys(get_object_vars($this)); |
|
2536 | 2536 | } |
2537 | 2537 | |
2538 | 2538 |