@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -432,7 +434,7 @@ discard block |
||
432 | 434 | if($include_expired === null){ |
433 | 435 | if($event instanceof EE_Event && $event->is_expired()){ |
434 | 436 | $include_expired = true; |
435 | - }else{ |
|
437 | + } else{ |
|
436 | 438 | $include_expired = false; |
437 | 439 | } |
438 | 440 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @access public |
40 | 40 | * @param int $EVT_ID |
41 | - * @return object |
|
41 | + * @return null|boolean |
|
42 | 42 | */ |
43 | 43 | public static function get_event( $EVT_ID = 0 ) { |
44 | 44 | $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @access public |
118 | 118 | * @param int $EVT_ID |
119 | - * @return string |
|
119 | + * @return boolean |
|
120 | 120 | */ |
121 | 121 | public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
122 | 122 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * event_active_status |
137 | 137 | * |
138 | 138 | * @access public |
139 | - * @param null $num_words |
|
139 | + * @param integer $num_words |
|
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @access public |
324 | 324 | * @param int $EVT_ID |
325 | - * @return string |
|
325 | + * @return string|null |
|
326 | 326 | */ |
327 | 327 | public static function get_primary_date_obj( $EVT_ID = 0 ) { |
328 | 328 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @access public |
349 | 349 | * @param int $EVT_ID |
350 | - * @return string |
|
350 | + * @return string|null |
|
351 | 351 | */ |
352 | 352 | public static function get_last_date_obj( $EVT_ID = 0 ) { |
353 | 353 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @access public |
374 | 374 | * @param int $EVT_ID |
375 | - * @return string |
|
375 | + * @return string|null |
|
376 | 376 | */ |
377 | 377 | public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
378 | 378 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @access public |
424 | 424 | * @param int $EVT_ID |
425 | - * @param null $include_expired |
|
425 | + * @param false|null $include_expired |
|
426 | 426 | * @param bool $include_deleted |
427 | 427 | * @param null $limit |
428 | 428 | * @return EE_Datetime[] |
@@ -40,27 +40,27 @@ discard block |
||
40 | 40 | * @param int $EVT_ID |
41 | 41 | * @return object |
42 | 42 | */ |
43 | - public static function get_event( $EVT_ID = 0 ) { |
|
44 | - $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
|
43 | + public static function get_event($EVT_ID = 0) { |
|
44 | + $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID); |
|
45 | 45 | // do we already have the Event you are looking for? |
46 | - if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) { |
|
46 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
47 | 47 | return EEH_Event_View::$_event; |
48 | 48 | } |
49 | 49 | EEH_Event_View::$_event = NULL; |
50 | 50 | // international newspaper? |
51 | 51 | global $post; |
52 | 52 | // if this is being called from an EE_Event post, then we can just grab the attached EE_Event object |
53 | - if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) { |
|
53 | + if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) { |
|
54 | 54 | // d( $post ); |
55 | 55 | // grab the event we're looking for |
56 | - if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) { |
|
56 | + if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) { |
|
57 | 57 | EEH_Event_View::$_event = $post->EE_Event; |
58 | 58 | // d( EEH_Event_View::$_event ); |
59 | 59 | } |
60 | 60 | // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID... |
61 | - if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) { |
|
61 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
62 | 62 | // sigh... pull it from the db |
63 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
63 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
64 | 64 | // d( EEH_Event_View::$_event ); |
65 | 65 | } |
66 | 66 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param int $EVT_ID |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - public static function display_ticket_selector( $EVT_ID = 0 ) { |
|
80 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
79 | + public static function display_ticket_selector($EVT_ID = 0) { |
|
80 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
81 | 81 | return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE; |
82 | 82 | } |
83 | 83 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param int $EVT_ID |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public static function event_status( $EVT_ID = 0 ) { |
|
94 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
95 | - return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : ''; |
|
93 | + public static function event_status($EVT_ID = 0) { |
|
94 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
95 | + return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : ''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param int $EVT_ID |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function event_active_status( $EVT_ID = 0 ) { |
|
108 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
107 | + public static function event_active_status($EVT_ID = 0) { |
|
108 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
109 | 109 | return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive'; |
110 | 110 | } |
111 | 111 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param int $EVT_ID |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
|
122 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
121 | + public static function event_has_content_or_excerpt($EVT_ID = 0) { |
|
122 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
123 | 123 | $has_content_or_excerpt = FALSE; |
124 | - if ( $event instanceof EE_Event ) { |
|
125 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE; |
|
124 | + if ($event instanceof EE_Event) { |
|
125 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE; |
|
126 | 126 | } |
127 | - if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) { |
|
127 | + if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) { |
|
128 | 128 | $has_content_or_excerpt = FALSE; |
129 | 129 | } |
130 | 130 | return $has_content_or_excerpt; |
@@ -140,45 +140,45 @@ discard block |
||
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
|
143 | + public static function event_content_or_excerpt($num_words = NULL, $more = NULL) { |
|
144 | 144 | global $post; |
145 | 145 | |
146 | 146 | ob_start(); |
147 | - if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
|
147 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
148 | 148 | |
149 | 149 | // admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option |
150 | 150 | the_content(); |
151 | 151 | |
152 | - } else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) { |
|
152 | + } else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
153 | 153 | |
154 | 154 | // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option |
155 | 155 | // AND an excerpt actually exists |
156 | 156 | the_excerpt(); |
157 | 157 | |
158 | - } else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) { |
|
158 | + } else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
159 | 159 | |
160 | 160 | // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option |
161 | 161 | // but NO excerpt actually exists, so we need to create one |
162 | - if ( ! empty( $num_words )) { |
|
163 | - if ( empty( $more )) { |
|
164 | - $more_link_text = __( '(more…)' ); |
|
165 | - $more = ' <a href="' . get_permalink() . '" class="more-link">' . $more_link_text . '</a>'; |
|
166 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
162 | + if ( ! empty($num_words)) { |
|
163 | + if (empty($more)) { |
|
164 | + $more_link_text = __('(more…)'); |
|
165 | + $more = ' <a href="'.get_permalink().'" class="more-link">'.$more_link_text.'</a>'; |
|
166 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
167 | 167 | } |
168 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
168 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
169 | 169 | |
170 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
170 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
171 | 171 | } else { |
172 | - $content = get_the_content(); |
|
172 | + $content = get_the_content(); |
|
173 | 173 | } |
174 | 174 | global $allowedtags; |
175 | - $content = wp_kses( $content, $allowedtags ); |
|
176 | - $content = strip_shortcodes( $content ); |
|
177 | - echo apply_filters( 'the_content', $content ); |
|
175 | + $content = wp_kses($content, $allowedtags); |
|
176 | + $content = strip_shortcodes($content); |
|
177 | + echo apply_filters('the_content', $content); |
|
178 | 178 | |
179 | 179 | } else { |
180 | 180 | // admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option |
181 | - echo apply_filters( 'the_content', '' ); |
|
181 | + echo apply_filters('the_content', ''); |
|
182 | 182 | } |
183 | 183 | return ob_get_clean(); |
184 | 184 | } |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * @param int $EVT_ID |
193 | 193 | * @return EE_Ticket[] |
194 | 194 | */ |
195 | - public static function event_tickets_available( $EVT_ID = 0 ) { |
|
196 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
195 | + public static function event_tickets_available($EVT_ID = 0) { |
|
196 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
197 | 197 | $tickets_available_for_purchase = array(); |
198 | - if( $event instanceof EE_Event ) { |
|
199 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE ); |
|
200 | - foreach( $datetimes as $datetime ) { |
|
201 | - $tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() ); |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE); |
|
200 | + foreach ($datetimes as $datetime) { |
|
201 | + $tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | return $tickets_available_for_purchase; |
@@ -214,22 +214,22 @@ discard block |
||
214 | 214 | * @param bool $hide_uncategorized |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) { |
|
217 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) { |
|
218 | 218 | $category_links = array(); |
219 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
220 | - if ( $event instanceof EE_Event ) { |
|
221 | - $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' ); |
|
222 | - if ( $event_categories ) { |
|
219 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
220 | + if ($event instanceof EE_Event) { |
|
221 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
222 | + if ($event_categories) { |
|
223 | 223 | // loop thru terms and create links |
224 | - foreach ( $event_categories as $term ) { |
|
225 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
226 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
227 | - $category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>'; |
|
224 | + foreach ($event_categories as $term) { |
|
225 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
226 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
227 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>'; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | - return implode( ', ', $category_links ); |
|
232 | + return implode(', ', $category_links); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @param int $EVT_ID |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
247 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
248 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
249 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
246 | + public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
247 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
248 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
249 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | * @param int $EVT_ID |
261 | 261 | * @return string |
262 | 262 | */ |
263 | - public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
264 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
265 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
266 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
263 | + public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
264 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
265 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
266 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | * @param int $EVT_ID |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
281 | - $datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID ); |
|
282 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
283 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
280 | + public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
281 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
282 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
283 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | * @param int $EVT_ID |
295 | 295 | * @return string |
296 | 296 | */ |
297 | - public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
298 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
299 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
300 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
297 | + public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
298 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
299 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
300 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | * @param int $EVT_ID |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - public static function event_date_as_calendar_page( $EVT_ID = 0 ) { |
|
313 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
314 | - if ( $datetime instanceof EE_Datetime ) { |
|
312 | + public static function event_date_as_calendar_page($EVT_ID = 0) { |
|
313 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
314 | + if ($datetime instanceof EE_Datetime) { |
|
315 | 315 | ?> |
316 | 316 | <div class="event-date-calendar-page-dv"> |
317 | - <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div> |
|
318 | - <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div> |
|
317 | + <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div> |
|
318 | + <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div> |
|
319 | 319 | </div> |
320 | 320 | <?php |
321 | 321 | } |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | * @param int $EVT_ID |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - public static function get_primary_date_obj( $EVT_ID = 0 ) { |
|
334 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
335 | - if ( $event instanceof EE_Event ) { |
|
333 | + public static function get_primary_date_obj($EVT_ID = 0) { |
|
334 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
335 | + if ($event instanceof EE_Event) { |
|
336 | 336 | $datetimes = $event->get_many_related( |
337 | 337 | 'Datetime', |
338 | 338 | array( |
339 | 339 | 'limit' => 1, |
340 | - 'order_by' => array( 'DTT_order' => 'ASC' ) |
|
340 | + 'order_by' => array('DTT_order' => 'ASC') |
|
341 | 341 | ) |
342 | 342 | ); |
343 | - return reset( $datetimes ); |
|
343 | + return reset($datetimes); |
|
344 | 344 | } else { |
345 | 345 | return FALSE; |
346 | 346 | } |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * @param int $EVT_ID |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public static function get_last_date_obj( $EVT_ID = 0 ) { |
|
359 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
360 | - if ( $event instanceof EE_Event ) { |
|
358 | + public static function get_last_date_obj($EVT_ID = 0) { |
|
359 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
360 | + if ($event instanceof EE_Event) { |
|
361 | 361 | $datetimes = $event->get_many_related( |
362 | 362 | 'Datetime', |
363 | 363 | array( |
364 | 364 | 'limit' => 1, |
365 | - 'order_by' => array( 'DTT_order' => 'DESC' ) |
|
365 | + 'order_by' => array('DTT_order' => 'DESC') |
|
366 | 366 | ) |
367 | 367 | ); |
368 | - return end( $datetimes ); |
|
368 | + return end($datetimes); |
|
369 | 369 | } else { |
370 | 370 | return FALSE; |
371 | 371 | } |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | * @param int $EVT_ID |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
|
384 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
385 | - if ( $event instanceof EE_Event ) { |
|
383 | + public static function get_earliest_date_obj($EVT_ID = 0) { |
|
384 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
385 | + if ($event instanceof EE_Event) { |
|
386 | 386 | $datetimes = $event->get_many_related( |
387 | 387 | 'Datetime', |
388 | 388 | array( |
389 | 389 | 'limit' => 1, |
390 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
390 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
391 | 391 | ) |
392 | 392 | ); |
393 | - return reset( $datetimes ); |
|
393 | + return reset($datetimes); |
|
394 | 394 | } else { |
395 | 395 | return FALSE; |
396 | 396 | } |
@@ -405,17 +405,17 @@ discard block |
||
405 | 405 | * @param int $EVT_ID |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - public static function get_latest_date_obj( $EVT_ID = 0 ) { |
|
409 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
410 | - if ( $event instanceof EE_Event ) { |
|
408 | + public static function get_latest_date_obj($EVT_ID = 0) { |
|
409 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
410 | + if ($event instanceof EE_Event) { |
|
411 | 411 | $datetimes = $event->get_many_related( |
412 | 412 | 'Datetime', |
413 | 413 | array( |
414 | 414 | 'limit' => 1, |
415 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
415 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
416 | 416 | ) |
417 | 417 | ); |
418 | - return end( $datetimes ); |
|
418 | + return end($datetimes); |
|
419 | 419 | } else { |
420 | 420 | return FALSE; |
421 | 421 | } |
@@ -433,17 +433,17 @@ discard block |
||
433 | 433 | * @param null $limit |
434 | 434 | * @return EE_Datetime[] |
435 | 435 | */ |
436 | - public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) { |
|
437 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
438 | - if($include_expired === null){ |
|
439 | - if($event instanceof EE_Event && $event->is_expired()){ |
|
436 | + public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) { |
|
437 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
438 | + if ($include_expired === null) { |
|
439 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
440 | 440 | $include_expired = true; |
441 | - }else{ |
|
441 | + } else { |
|
442 | 442 | $include_expired = false; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - if ( $event instanceof EE_Event ) { |
|
446 | + if ($event instanceof EE_Event) { |
|
447 | 447 | return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
448 | 448 | } else { |
449 | 449 | return array(); |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | * @param int $EVT_ID |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - public static function event_link_url( $EVT_ID = 0 ) { |
|
463 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
464 | - if ( $event instanceof EE_Event ) { |
|
465 | - $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() ); |
|
466 | - return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url; |
|
462 | + public static function event_link_url($EVT_ID = 0) { |
|
463 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
464 | + if ($event instanceof EE_Event) { |
|
465 | + $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID()); |
|
466 | + return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url; |
|
467 | 467 | } |
468 | 468 | return NULL; |
469 | 469 | } |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | * @param int $EVT_ID |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public static function event_phone( $EVT_ID = 0 ) { |
|
481 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
482 | - if ( $event instanceof EE_Event ) { |
|
483 | - return EEH_Schema::telephone( $event->phone() ); |
|
480 | + public static function event_phone($EVT_ID = 0) { |
|
481 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
482 | + if ($event instanceof EE_Event) { |
|
483 | + return EEH_Schema::telephone($event->phone()); |
|
484 | 484 | } |
485 | 485 | return NULL; |
486 | 486 | } |
@@ -497,23 +497,23 @@ discard block |
||
497 | 497 | * @param string $after |
498 | 498 | * @return string |
499 | 499 | */ |
500 | - public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) { |
|
501 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
502 | - if ( $event instanceof EE_Event ) { |
|
500 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') { |
|
501 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
502 | + if ($event instanceof EE_Event) { |
|
503 | 503 | // can the user edit this post ? |
504 | - if ( current_user_can( 'edit_post', $event->ID() )) { |
|
504 | + if (current_user_can('edit_post', $event->ID())) { |
|
505 | 505 | // set link text |
506 | - $link = ! empty( $link ) ? $link : __('edit this event'); |
|
506 | + $link = ! empty($link) ? $link : __('edit this event'); |
|
507 | 507 | // generate nonce |
508 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
508 | + $nonce = wp_create_nonce('edit_nonce'); |
|
509 | 509 | // generate url to event editor for this event |
510 | - $url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() ); |
|
510 | + $url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url()); |
|
511 | 511 | // get edit CPT text |
512 | - $post_type_obj = get_post_type_object( 'espresso_events' ); |
|
512 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
513 | 513 | // build final link html |
514 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>'; |
|
514 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
515 | 515 | // put it all together |
516 | - return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after; |
|
516 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
517 | 517 | } |
518 | 518 | } |
519 | 519 | return ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,19 +363,19 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | |
374 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
374 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
375 | 375 | //Debug |
376 | 376 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
377 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
378 | - $field .= ' ' . $parameters; |
|
377 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
378 | + $field .= ' '.$parameters; |
|
379 | 379 | if ($autosize) { |
380 | 380 | $size = 'med'; |
381 | 381 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -388,21 +388,21 @@ discard block |
||
388 | 388 | $size = ''; |
389 | 389 | } |
390 | 390 | |
391 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
391 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
392 | 392 | |
393 | 393 | if (empty($default) && isset($GLOBALS[$name])) |
394 | 394 | $default = stripslashes($GLOBALS[$name]); |
395 | 395 | |
396 | 396 | |
397 | 397 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
398 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
398 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
399 | 399 | if ($default == $values[$i]['id']) { |
400 | 400 | $field .= ' selected = "selected"'; |
401 | 401 | } |
402 | - if ( isset( $values[$i]['class'] ) ) { |
|
403 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
402 | + if (isset($values[$i]['class'])) { |
|
403 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
404 | 404 | } |
405 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
405 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
406 | 406 | } |
407 | 407 | $field .= '</select>'; |
408 | 408 | |
@@ -420,38 +420,38 @@ discard block |
||
420 | 420 | * @param string $question_groups |
421 | 421 | * @return string HTML |
422 | 422 | */ |
423 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
423 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
424 | 424 | |
425 | 425 | $html = ''; |
426 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
427 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
426 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
427 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
428 | 428 | |
429 | - if ( ! empty( $question_groups )) { |
|
429 | + if ( ! empty($question_groups)) { |
|
430 | 430 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
431 | 431 | // loop thru question groups |
432 | - foreach ( $question_groups as $QSG ) { |
|
432 | + foreach ($question_groups as $QSG) { |
|
433 | 433 | // check that questions exist |
434 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
434 | + if ( ! empty($QSG['QSG_questions'])) { |
|
435 | 435 | // use fieldsets |
436 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
436 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
437 | 437 | // group_name |
438 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
438 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
439 | 439 | // group_desc |
440 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
440 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
441 | 441 | |
442 | 442 | $html .= $before_question_group_questions; |
443 | 443 | // loop thru questions |
444 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
444 | + foreach ($QSG['QSG_questions'] as $question) { |
|
445 | 445 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
446 | 446 | $QFI = new EE_Question_Form_Input( |
447 | 447 | $question['qst_obj'], |
448 | 448 | $question['ans_obj'], |
449 | 449 | $question |
450 | 450 | ); |
451 | - $html .= self::generate_form_input( $QFI ); |
|
451 | + $html .= self::generate_form_input($QFI); |
|
452 | 452 | } |
453 | 453 | $html .= $after_question_group_questions; |
454 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
454 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | * @param string $group_wrapper |
472 | 472 | * @return string HTML |
473 | 473 | */ |
474 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
474 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
475 | 475 | |
476 | 476 | $html = ''; |
477 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
478 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
477 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
478 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
479 | 479 | |
480 | 480 | $default_q_meta = array( |
481 | 481 | 'att_nmbr' => 1, |
@@ -484,55 +484,55 @@ discard block |
||
484 | 484 | 'input_id' => '', |
485 | 485 | 'input_class' => '' |
486 | 486 | ); |
487 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
487 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
488 | 488 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
489 | 489 | |
490 | - if ( ! empty( $question_groups )) { |
|
490 | + if ( ! empty($question_groups)) { |
|
491 | 491 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | // loop thru question groups |
493 | - foreach ( $question_groups as $QSG ) { |
|
494 | - if ( $QSG instanceof EE_Question_Group ) { |
|
493 | + foreach ($question_groups as $QSG) { |
|
494 | + if ($QSG instanceof EE_Question_Group) { |
|
495 | 495 | // check that questions exist |
496 | 496 | |
497 | - $where = array( 'QST_deleted' => 0 ); |
|
498 | - if ( ! $from_admin ) { |
|
497 | + $where = array('QST_deleted' => 0); |
|
498 | + if ( ! $from_admin) { |
|
499 | 499 | $where['QST_admin_only'] = 0; |
500 | 500 | } |
501 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
502 | - if ( ! empty( $questions )) { |
|
501 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
502 | + if ( ! empty($questions)) { |
|
503 | 503 | // use fieldsets |
504 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
504 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
505 | 505 | // group_name |
506 | - if ( $QSG->show_group_name() ) { |
|
507 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
506 | + if ($QSG->show_group_name()) { |
|
507 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
508 | 508 | } |
509 | 509 | // group_desc |
510 | - if ( $QSG->show_group_desc() ) { |
|
511 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
510 | + if ($QSG->show_group_desc()) { |
|
511 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $html .= $before_question_group_questions; |
515 | 515 | // loop thru questions |
516 | - foreach ( $questions as $QST ) { |
|
516 | + foreach ($questions as $QST) { |
|
517 | 517 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
518 | 518 | |
519 | 519 | $answer = NULL; |
520 | 520 | |
521 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
521 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
522 | 522 | // check for answer in $_GET in case we are reprocessing a form after an error |
523 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
524 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
523 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
524 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
525 | 525 | } |
526 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
526 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
527 | 527 | //attendee data from the session |
528 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
528 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | |
532 | 532 | |
533 | 533 | $QFI = new EE_Question_Form_Input( |
534 | 534 | $QST, |
535 | - EE_Answer::new_instance ( array( |
|
535 | + EE_Answer::new_instance(array( |
|
536 | 536 | 'ANS_ID'=> 0, |
537 | 537 | 'QST_ID'=> 0, |
538 | 538 | 'REG_ID'=> 0, |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | $q_meta |
542 | 542 | ); |
543 | 543 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
544 | - $html .= self::generate_form_input( $QFI ); |
|
544 | + $html .= self::generate_form_input($QFI); |
|
545 | 545 | } |
546 | 546 | $html .= $after_question_group_questions; |
547 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
547 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | } |
@@ -564,63 +564,63 @@ discard block |
||
564 | 564 | * @param EE_Question_Form_Input $QFI |
565 | 565 | * @return string HTML |
566 | 566 | */ |
567 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
568 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
567 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
568 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
569 | 569 | return ''; |
570 | 570 | } |
571 | 571 | |
572 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
573 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
572 | + $QFI = self::_load_system_dropdowns($QFI); |
|
573 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
574 | 574 | |
575 | 575 | //we also need to verify |
576 | 576 | |
577 | 577 | $display_text = $QFI->get('QST_display_text'); |
578 | 578 | $input_name = $QFI->get('QST_input_name'); |
579 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
579 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
580 | 580 | $input_id = $QFI->get('QST_input_id'); |
581 | 581 | $input_class = $QFI->get('QST_input_class'); |
582 | 582 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
583 | 583 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
584 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
584 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
585 | 585 | $QST_required = $QFI->get('QST_required'); |
586 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
587 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
588 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
589 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
586 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
587 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
588 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
589 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
590 | 590 | $label_class = 'espresso-form-input-lbl'; |
591 | - $QST_options = $QFI->options(true,$answer); |
|
592 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
591 | + $QST_options = $QFI->options(true, $answer); |
|
592 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
593 | 593 | $system_ID = $QFI->get('QST_system'); |
594 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
595 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
594 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
595 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
596 | 596 | |
597 | 597 | |
598 | - switch ( $QFI->get('QST_type') ){ |
|
598 | + switch ($QFI->get('QST_type')) { |
|
599 | 599 | |
600 | 600 | case 'TEXTAREA' : |
601 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
601 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
602 | 602 | break; |
603 | 603 | |
604 | 604 | case 'DROPDOWN' : |
605 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
605 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
606 | 606 | break; |
607 | 607 | |
608 | 608 | |
609 | 609 | case 'RADIO_BTN' : |
610 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
610 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'CHECKBOX' : |
614 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
614 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | case 'DATE' : |
618 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
618 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'TEXT' : |
622 | 622 | default: |
623 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
623 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
624 | 624 | break; |
625 | 625 | |
626 | 626 | } |
@@ -646,31 +646,31 @@ discard block |
||
646 | 646 | * @param string $disabled disabled="disabled" or null |
647 | 647 | * @return string HTML |
648 | 648 | */ |
649 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
649 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
650 | 650 | // need these |
651 | - if ( ! $question || ! $name ) { |
|
651 | + if ( ! $question || ! $name) { |
|
652 | 652 | return NULL; |
653 | 653 | } |
654 | 654 | // prep the answer |
655 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
655 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
656 | 656 | // prep the required array |
657 | - $required = self::prep_required( $required ); |
|
657 | + $required = self::prep_required($required); |
|
658 | 658 | // set disabled tag |
659 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
659 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
660 | 660 | // ya gots ta have style man!!! |
661 | 661 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
662 | - $class = empty( $class ) ? $txt_class : $class; |
|
663 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
664 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
662 | + $class = empty($class) ? $txt_class : $class; |
|
663 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
664 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
665 | 665 | |
666 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
666 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
667 | 667 | // filter label but ensure required text comes before it |
668 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
668 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
669 | 669 | |
670 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
670 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
671 | 671 | |
672 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
673 | - return $label_html . $input_html; |
|
672 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
673 | + return $label_html.$input_html; |
|
674 | 674 | |
675 | 675 | } |
676 | 676 | |
@@ -692,35 +692,35 @@ discard block |
||
692 | 692 | * @param string $disabled disabled="disabled" or null |
693 | 693 | * @return string HTML |
694 | 694 | */ |
695 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
695 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
696 | 696 | // need these |
697 | - if ( ! $question || ! $name ) { |
|
697 | + if ( ! $question || ! $name) { |
|
698 | 698 | return NULL; |
699 | 699 | } |
700 | 700 | // prep the answer |
701 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
701 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
702 | 702 | // prep the required array |
703 | - $required = self::prep_required( $required ); |
|
703 | + $required = self::prep_required($required); |
|
704 | 704 | // make sure $dimensions is an array |
705 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
705 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
706 | 706 | // and set some defaults |
707 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
707 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
708 | 708 | // set disabled tag |
709 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
709 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
710 | 710 | // ya gots ta have style man!!! |
711 | 711 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
712 | - $class = empty( $class ) ? $txt_class : $class; |
|
713 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
714 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
712 | + $class = empty($class) ? $txt_class : $class; |
|
713 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
714 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
715 | 715 | |
716 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
716 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
717 | 717 | // filter label but ensure required text comes before it |
718 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
718 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
719 | 719 | |
720 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
720 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
721 | 721 | |
722 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
723 | - return $label_html . $input_html; |
|
722 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
723 | + return $label_html.$input_html; |
|
724 | 724 | |
725 | 725 | } |
726 | 726 | |
@@ -743,47 +743,47 @@ discard block |
||
743 | 743 | * @param string $disabled disabled="disabled" or null |
744 | 744 | * @return string HTML |
745 | 745 | */ |
746 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
746 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
747 | 747 | |
748 | 748 | // need these |
749 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
749 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
750 | 750 | return NULL; |
751 | 751 | } |
752 | 752 | // prep the answer |
753 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
753 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
754 | 754 | // prep the required array |
755 | - $required = self::prep_required( $required ); |
|
755 | + $required = self::prep_required($required); |
|
756 | 756 | // set disabled tag |
757 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
757 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
758 | 758 | // ya gots ta have style man!!! |
759 | 759 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
760 | - $class = empty( $class ) ? $txt_class : $class; |
|
761 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
762 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
760 | + $class = empty($class) ? $txt_class : $class; |
|
761 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
762 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
763 | 763 | |
764 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
764 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
765 | 765 | // filter label but ensure required text comes before it |
766 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
766 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
767 | 767 | |
768 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
768 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
769 | 769 | // recursively count array elements, to determine total number of options |
770 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
771 | - if ( ! $only_option ) { |
|
770 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
771 | + if ( ! $only_option) { |
|
772 | 772 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
773 | 773 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
774 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
774 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
775 | 775 | } |
776 | - foreach ( $options as $key => $value ) { |
|
776 | + foreach ($options as $key => $value) { |
|
777 | 777 | // if value is an array, then create option groups, else create regular ol' options |
778 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
778 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
779 | 779 | } |
780 | 780 | |
781 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
781 | + $input_html .= "\n\t\t\t".'</select>'; |
|
782 | 782 | |
783 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
783 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
784 | 784 | |
785 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
786 | - return $label_html . $input_html; |
|
785 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
786 | + return $label_html.$input_html; |
|
787 | 787 | |
788 | 788 | } |
789 | 789 | |
@@ -801,12 +801,12 @@ discard block |
||
801 | 801 | * @param boolean $use_html_entities |
802 | 802 | * @return string |
803 | 803 | */ |
804 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
805 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
806 | - foreach ( $QSOs as $QSO ) { |
|
807 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
804 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
805 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
806 | + foreach ($QSOs as $QSO) { |
|
807 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
808 | 808 | } |
809 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
809 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
810 | 810 | return $html; |
811 | 811 | } |
812 | 812 | |
@@ -821,12 +821,12 @@ discard block |
||
821 | 821 | * @param boolean $use_html_entities |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
825 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
826 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
827 | - $value = ! empty( $value ) ? $value : $key; |
|
828 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
829 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
824 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
825 | + $key = self::prep_answer($key, $use_html_entities); |
|
826 | + $value = self::prep_answer($value, $use_html_entities); |
|
827 | + $value = ! empty($value) ? $value : $key; |
|
828 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
829 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -850,56 +850,56 @@ discard block |
||
850 | 850 | * @param bool $use_desc_4_label |
851 | 851 | * @return string HTML |
852 | 852 | */ |
853 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
853 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
854 | 854 | // need these |
855 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
855 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
856 | 856 | return NULL; |
857 | 857 | } |
858 | 858 | // prep the answer |
859 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
859 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
860 | 860 | // prep the required array |
861 | - $required = self::prep_required( $required ); |
|
861 | + $required = self::prep_required($required); |
|
862 | 862 | // set disabled tag |
863 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
863 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
864 | 864 | // ya gots ta have style man!!! |
865 | 865 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
866 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
867 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
866 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
867 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
868 | 868 | |
869 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
869 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
870 | 870 | // filter label but ensure required text comes before it |
871 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
871 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
872 | 872 | |
873 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
873 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
874 | 874 | |
875 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
876 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
875 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
876 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
877 | 877 | |
878 | - foreach ( $options as $OPT ) { |
|
879 | - if ( $OPT instanceof EE_Question_Option ) { |
|
880 | - $value = self::prep_option_value( $OPT->value() ); |
|
878 | + foreach ($options as $OPT) { |
|
879 | + if ($OPT instanceof EE_Question_Option) { |
|
880 | + $value = self::prep_option_value($OPT->value()); |
|
881 | 881 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
882 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
883 | - $desc = $OPT->desc();//no self::prep_answer |
|
884 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
885 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
886 | - $opt = '-' . sanitize_key( $value ); |
|
887 | - |
|
888 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
889 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
890 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
891 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
892 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
893 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
894 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
895 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
882 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
883 | + $desc = $OPT->desc(); //no self::prep_answer |
|
884 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
885 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
886 | + $opt = '-'.sanitize_key($value); |
|
887 | + |
|
888 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
889 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
890 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
891 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
892 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
893 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
894 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
895 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
899 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
900 | 900 | |
901 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
902 | - return $label_html . $input_html; |
|
901 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
902 | + return $label_html.$input_html; |
|
903 | 903 | |
904 | 904 | } |
905 | 905 | |
@@ -922,65 +922,65 @@ discard block |
||
922 | 922 | * @param string $disabled disabled="disabled" or null |
923 | 923 | * @return string HTML |
924 | 924 | */ |
925 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
925 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
926 | 926 | // need these |
927 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
927 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
928 | 928 | return NULL; |
929 | 929 | } |
930 | - $answer = maybe_unserialize( $answer ); |
|
930 | + $answer = maybe_unserialize($answer); |
|
931 | 931 | |
932 | 932 | // prep the answer(s) |
933 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
933 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
934 | 934 | |
935 | - foreach ( $answer as $key => $value ) { |
|
936 | - $key = self::prep_option_value( $key ); |
|
937 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
935 | + foreach ($answer as $key => $value) { |
|
936 | + $key = self::prep_option_value($key); |
|
937 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | // prep the required array |
941 | - $required = self::prep_required( $required ); |
|
941 | + $required = self::prep_required($required); |
|
942 | 942 | // set disabled tag |
943 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
943 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
944 | 944 | // ya gots ta have style man!!! |
945 | 945 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
946 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
947 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
946 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
947 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
948 | 948 | |
949 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
949 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
950 | 950 | // filter label but ensure required text comes before it |
951 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
952 | - |
|
953 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
954 | - |
|
955 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
956 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
957 | - |
|
958 | - foreach ( $options as $OPT ) { |
|
959 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
960 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
961 | - $text = self::prep_answer( $OPT->value() ); |
|
962 | - $desc = $OPT->desc() ; |
|
963 | - $opt = '-' . sanitize_key( $value ); |
|
964 | - |
|
965 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
966 | - |
|
967 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
968 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
969 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
970 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
971 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
972 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
973 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
974 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
951 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
952 | + |
|
953 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
954 | + |
|
955 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
956 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
957 | + |
|
958 | + foreach ($options as $OPT) { |
|
959 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
960 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
961 | + $text = self::prep_answer($OPT->value()); |
|
962 | + $desc = $OPT->desc(); |
|
963 | + $opt = '-'.sanitize_key($value); |
|
964 | + |
|
965 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
966 | + |
|
967 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
968 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
969 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
970 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
971 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
972 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
973 | + if ( ! empty($desc) && $desc != $text) { |
|
974 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
975 | 975 | } |
976 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
976 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
977 | 977 | |
978 | 978 | } |
979 | 979 | |
980 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
980 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
981 | 981 | |
982 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
983 | - return $label_html . $input_html; |
|
982 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
983 | + return $label_html.$input_html; |
|
984 | 984 | |
985 | 985 | } |
986 | 986 | |
@@ -1002,36 +1002,36 @@ discard block |
||
1002 | 1002 | * @param string $disabled disabled="disabled" or null |
1003 | 1003 | * @return string HTML |
1004 | 1004 | */ |
1005 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1005 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1006 | 1006 | // need these |
1007 | - if ( ! $question || ! $name ) { |
|
1007 | + if ( ! $question || ! $name) { |
|
1008 | 1008 | return NULL; |
1009 | 1009 | } |
1010 | 1010 | // prep the answer |
1011 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1011 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1012 | 1012 | // prep the required array |
1013 | - $required = self::prep_required( $required ); |
|
1013 | + $required = self::prep_required($required); |
|
1014 | 1014 | // set disabled tag |
1015 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1015 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1016 | 1016 | // ya gots ta have style man!!! |
1017 | 1017 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1018 | - $class = empty( $class ) ? $txt_class : $class; |
|
1019 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1020 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1018 | + $class = empty($class) ? $txt_class : $class; |
|
1019 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1020 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1021 | 1021 | |
1022 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1022 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1023 | 1023 | // filter label but ensure required text comes before it |
1024 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1024 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1025 | 1025 | |
1026 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1026 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1027 | 1027 | |
1028 | 1028 | // enqueue scripts |
1029 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1030 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1031 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1029 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1030 | + wp_enqueue_style('espresso-ui-theme'); |
|
1031 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1032 | 1032 | |
1033 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1034 | - return $label_html . $input_html; |
|
1033 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1034 | + return $label_html.$input_html; |
|
1035 | 1035 | |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * @access public |
1044 | 1044 | * @return string |
1045 | 1045 | */ |
1046 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1046 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1047 | 1047 | return $required_text; |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1057,9 +1057,9 @@ discard block |
||
1057 | 1057 | * @param string $value |
1058 | 1058 | * @return string HTML |
1059 | 1059 | */ |
1060 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1061 | - $id = ! empty( $id ) ? $id : $name; |
|
1062 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1060 | + static function hidden_input($name, $value, $id = '') { |
|
1061 | + $id = ! empty($id) ? $id : $name; |
|
1062 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | * @param string $question |
1072 | 1072 | * @return string |
1073 | 1073 | */ |
1074 | - static function prep_question( $question ){ |
|
1074 | + static function prep_question($question) { |
|
1075 | 1075 | return $question; |
1076 | 1076 | // $link = ''; |
1077 | 1077 | // // does this label have a help link attached ? |
@@ -1094,13 +1094,13 @@ discard block |
||
1094 | 1094 | * @param mixed $answer |
1095 | 1095 | * @return string |
1096 | 1096 | */ |
1097 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1097 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1098 | 1098 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1099 | - if ( is_bool( $answer ) ) { |
|
1099 | + if (is_bool($answer)) { |
|
1100 | 1100 | $answer = $answer ? 1 : 0; |
1101 | 1101 | } |
1102 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1103 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1102 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1103 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | |
@@ -1110,18 +1110,18 @@ discard block |
||
1110 | 1110 | * @param array $QSOs array of EE_Question_Option objects |
1111 | 1111 | * @return array |
1112 | 1112 | */ |
1113 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1113 | + public static function prep_answer_options($QSOs = array()) { |
|
1114 | 1114 | $prepped_answer_options = array(); |
1115 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1116 | - foreach( $QSOs as $key => $QSO ) { |
|
1117 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1118 | - $QSO = EE_Question_Option::new_instance( array( |
|
1119 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1120 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1115 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1116 | + foreach ($QSOs as $key => $QSO) { |
|
1117 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1118 | + $QSO = EE_Question_Option::new_instance(array( |
|
1119 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1120 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1121 | 1121 | )); |
1122 | 1122 | } |
1123 | - if ( $QSO->opt_group() ) { |
|
1124 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1123 | + if ($QSO->opt_group()) { |
|
1124 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1125 | 1125 | } else { |
1126 | 1126 | $prepped_answer_options[] = $QSO; |
1127 | 1127 | } |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | * @param string $option_value |
1138 | 1138 | * @return string |
1139 | 1139 | */ |
1140 | - static function prep_option_value( $option_value ){ |
|
1141 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1140 | + static function prep_option_value($option_value) { |
|
1141 | + return esc_attr(trim(stripslashes($option_value))); |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | |
@@ -1149,11 +1149,11 @@ discard block |
||
1149 | 1149 | * @param string|array $required |
1150 | 1150 | * @return array |
1151 | 1151 | */ |
1152 | - static function prep_required( $required = array() ){ |
|
1152 | + static function prep_required($required = array()) { |
|
1153 | 1153 | // make sure required is an array |
1154 | - $required = is_array( $required ) ? $required : array(); |
|
1154 | + $required = is_array($required) ? $required : array(); |
|
1155 | 1155 | // and set some defaults |
1156 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1156 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1157 | 1157 | return $required; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1164,30 +1164,30 @@ discard block |
||
1164 | 1164 | * @param string $value |
1165 | 1165 | * @return string |
1166 | 1166 | */ |
1167 | - static function get_label_size_class( $value = FALSE ){ |
|
1168 | - if ( $value === FALSE || $value == '' ) { |
|
1167 | + static function get_label_size_class($value = FALSE) { |
|
1168 | + if ($value === FALSE || $value == '') { |
|
1169 | 1169 | return ' class="medium-lbl"'; |
1170 | 1170 | } |
1171 | 1171 | // determine length of option value |
1172 | - $val_size = strlen( $value ); |
|
1173 | - switch( $val_size ){ |
|
1172 | + $val_size = strlen($value); |
|
1173 | + switch ($val_size) { |
|
1174 | 1174 | case $val_size < 3 : |
1175 | - $size = ' class="nano-lbl"'; |
|
1175 | + $size = ' class="nano-lbl"'; |
|
1176 | 1176 | break; |
1177 | 1177 | case $val_size < 6 : |
1178 | - $size = ' class="micro-lbl"'; |
|
1178 | + $size = ' class="micro-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 12 : |
1181 | - $size = ' class="tiny-lbl"'; |
|
1181 | + $size = ' class="tiny-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 25 : |
1184 | - $size = ' class="small-lbl"'; |
|
1184 | + $size = ' class="small-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size > 100 : |
1187 | - $size = ' class="big-lbl"'; |
|
1187 | + $size = ' class="big-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | default: |
1190 | - $size = ' class="medium-lbl"'; |
|
1190 | + $size = ' class="medium-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | } |
1193 | 1193 | return $size; |
@@ -1201,20 +1201,20 @@ discard block |
||
1201 | 1201 | * @param array $QFI |
1202 | 1202 | * @return array |
1203 | 1203 | */ |
1204 | - private static function _load_system_dropdowns( $QFI ){ |
|
1204 | + private static function _load_system_dropdowns($QFI) { |
|
1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
1206 | - switch ( $QST_system ) { |
|
1206 | + switch ($QST_system) { |
|
1207 | 1207 | case 'state' : |
1208 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1208 | + $QFI = self::generate_state_dropdown($QFI); |
|
1209 | 1209 | break; |
1210 | 1210 | case 'country' : |
1211 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_country_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'admin-state' : |
1214 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1214 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-country' : |
1217 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | } |
1220 | 1220 | return $QFI; |
@@ -1231,13 +1231,13 @@ discard block |
||
1231 | 1231 | * |
1232 | 1232 | * @return EE_Question_Form_Input |
1233 | 1233 | */ |
1234 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1235 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1234 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1235 | + switch ($QFI->get('QST_type')) { |
|
1236 | 1236 | case 'STATE' : |
1237 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1237 | + $QFI = self::generate_state_dropdown($QFI); |
|
1238 | 1238 | break; |
1239 | 1239 | case 'COUNTRY' : |
1240 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_country_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | } |
1243 | 1243 | return $QFI; |
@@ -1251,23 +1251,23 @@ discard block |
||
1251 | 1251 | * @param bool $get_all |
1252 | 1252 | * @return array |
1253 | 1253 | */ |
1254 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1254 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1255 | 1255 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1256 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1257 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1256 | + if ($states && count($states) != count($QST->options())) { |
|
1257 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1258 | 1258 | // if multiple countries, we'll create option groups within the dropdown |
1259 | - foreach ( $states as $state ) { |
|
1260 | - if ( $state instanceof EE_State ) { |
|
1261 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1259 | + foreach ($states as $state) { |
|
1260 | + if ($state instanceof EE_State) { |
|
1261 | + $QSO = EE_Question_Option::new_instance(array( |
|
1262 | 1262 | 'QSO_value' => $state->ID(), |
1263 | 1263 | 'QSO_desc' => $state->name(), |
1264 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1264 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1265 | 1265 | 'QSO_deleted' => FALSE |
1266 | 1266 | )); |
1267 | 1267 | // set option group |
1268 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1268 | + $QSO->set_opt_group($state->country()->name()); |
|
1269 | 1269 | // add option to question |
1270 | - $QST->add_temp_option( $QSO ); |
|
1270 | + $QST->add_temp_option($QSO); |
|
1271 | 1271 | } |
1272 | 1272 | } |
1273 | 1273 | } |
@@ -1283,20 +1283,20 @@ discard block |
||
1283 | 1283 | * @internal param array $question |
1284 | 1284 | * @return array |
1285 | 1285 | */ |
1286 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1286 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1287 | 1287 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1288 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1289 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1288 | + if ($countries && count($countries) != count($QST->options())) { |
|
1289 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1290 | 1290 | // now add countries |
1291 | - foreach ( $countries as $country ) { |
|
1292 | - if ( $country instanceof EE_Country ) { |
|
1293 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1291 | + foreach ($countries as $country) { |
|
1292 | + if ($country instanceof EE_Country) { |
|
1293 | + $QSO = EE_Question_Option::new_instance(array( |
|
1294 | 1294 | 'QSO_value' => $country->ID(), |
1295 | 1295 | 'QSO_desc' => $country->name(), |
1296 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1296 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1297 | 1297 | 'QSO_deleted' => FALSE |
1298 | 1298 | )); |
1299 | - $QST->add_temp_option( $QSO ); |
|
1299 | + $QST->add_temp_option($QSO); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | } |
@@ -1313,11 +1313,11 @@ discard block |
||
1313 | 1313 | */ |
1314 | 1314 | public static function two_digit_months_dropdown_options() { |
1315 | 1315 | $options = array(); |
1316 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1317 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1318 | - $options[ (string)$mm ] = (string)$mm; |
|
1316 | + for ($x = 1; $x <= 12; $x++) { |
|
1317 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1318 | + $options[(string) $mm] = (string) $mm; |
|
1319 | 1319 | } |
1320 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1320 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | |
@@ -1332,11 +1332,11 @@ discard block |
||
1332 | 1332 | $options = array(); |
1333 | 1333 | $current_year = date('y'); |
1334 | 1334 | $next_decade = $current_year + 10; |
1335 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1336 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1337 | - $options[ (string)$yy ] = (string)$yy; |
|
1335 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1336 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1337 | + $options[(string) $yy] = (string) $yy; |
|
1338 | 1338 | } |
1339 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1339 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1350,17 +1350,17 @@ discard block |
||
1350 | 1350 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1351 | 1351 | * @return string html |
1352 | 1352 | */ |
1353 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1353 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1354 | 1354 | $_where = array(); |
1355 | - if ( !empty( $status ) ) { |
|
1355 | + if ( ! empty($status)) { |
|
1356 | 1356 | $_where['STS_ID'] = $status; |
1357 | 1357 | } |
1358 | 1358 | |
1359 | - if ( $evt_category > 0 ) { |
|
1359 | + if ($evt_category > 0) { |
|
1360 | 1360 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1361 | 1361 | } |
1362 | 1362 | |
1363 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1363 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1364 | 1364 | |
1365 | 1365 | //setup vals for select input helper |
1366 | 1366 | $options = array( |
@@ -1370,15 +1370,15 @@ discard block |
||
1370 | 1370 | ) |
1371 | 1371 | ); |
1372 | 1372 | |
1373 | - foreach ( $regdtts as $regdtt ) { |
|
1374 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1373 | + foreach ($regdtts as $regdtt) { |
|
1374 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1375 | 1375 | $options[] = array( |
1376 | 1376 | 'text' => $date, |
1377 | 1377 | 'id' => $date |
1378 | 1378 | ); |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1381 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | |
@@ -1392,18 +1392,18 @@ discard block |
||
1392 | 1392 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1393 | 1393 | * @return string html |
1394 | 1394 | */ |
1395 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1395 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1396 | 1396 | //determine what post_status our condition will have for the query. |
1397 | - switch ( $status ) { |
|
1397 | + switch ($status) { |
|
1398 | 1398 | case 'month' : |
1399 | 1399 | case 'today' : |
1400 | 1400 | case NULL : |
1401 | 1401 | case 'all' : |
1402 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1402 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1403 | 1403 | break; |
1404 | 1404 | |
1405 | 1405 | case 'draft' : |
1406 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1406 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1407 | 1407 | |
1408 | 1408 | default : |
1409 | 1409 | $where['Event.status'] = $status; |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | //categories? |
1413 | 1413 | |
1414 | 1414 | |
1415 | - if ( !empty ( $evt_category ) ) { |
|
1415 | + if ( ! empty ($evt_category)) { |
|
1416 | 1416 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1417 | 1417 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1418 | 1418 | } |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | |
1421 | 1421 | // $where['DTT_is_primary'] = 1; |
1422 | 1422 | |
1423 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1423 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1424 | 1424 | |
1425 | 1425 | //let's setup vals for select input helper |
1426 | 1426 | $options = array( |
@@ -1435,9 +1435,9 @@ discard block |
||
1435 | 1435 | //translate month and date |
1436 | 1436 | global $wp_locale; |
1437 | 1437 | |
1438 | - foreach ( $DTTS as $DTT ) { |
|
1439 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1440 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1438 | + foreach ($DTTS as $DTT) { |
|
1439 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1440 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1441 | 1441 | $options[] = array( |
1442 | 1442 | 'text' => $localized_date, |
1443 | 1443 | 'id' => $id |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | |
1448 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1448 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | * @param integer $current_cat currently selected category |
1457 | 1457 | * @return string html for dropdown |
1458 | 1458 | */ |
1459 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1459 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1460 | 1460 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1461 | 1461 | $options = array( |
1462 | 1462 | '0' => array( |
@@ -1466,14 +1466,14 @@ discard block |
||
1466 | 1466 | ); |
1467 | 1467 | |
1468 | 1468 | //setup categories for dropdown |
1469 | - foreach ( $categories as $category ) { |
|
1469 | + foreach ($categories as $category) { |
|
1470 | 1470 | $options[] = array( |
1471 | 1471 | 'text' => $category->get('name'), |
1472 | 1472 | 'id' => $category->ID() |
1473 | 1473 | ); |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1476 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | |
@@ -1492,20 +1492,20 @@ discard block |
||
1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1493 | 1493 | * @return void |
1494 | 1494 | */ |
1495 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1495 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1496 | 1496 | $btn = ''; |
1497 | - if ( empty( $url ) || empty( $ID )) { |
|
1497 | + if (empty($url) || empty($ID)) { |
|
1498 | 1498 | return $btn; |
1499 | 1499 | } |
1500 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1501 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1502 | - if ( ! $input_only ) { |
|
1503 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1504 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1500 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1501 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1502 | + if ( ! $input_only) { |
|
1503 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1504 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1505 | 1505 | $btn_frm .= $btn; |
1506 | 1506 | $btn_frm .= '</form>'; |
1507 | 1507 | $btn = $btn_frm; |
1508 | - unset ( $btn_frm ); |
|
1508 | + unset ($btn_frm); |
|
1509 | 1509 | } |
1510 | 1510 | return $btn; |
1511 | 1511 | } |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @param mixed $opt_group |
799 | 799 | * @param mixed $QSOs |
800 | - * @param mixed $answer |
|
800 | + * @param string $answer |
|
801 | 801 | * @param boolean $use_html_entities |
802 | 802 | * @return string |
803 | 803 | */ |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | /** |
1148 | 1148 | * prep_required |
1149 | 1149 | * @param string|array $required |
1150 | - * @return array |
|
1150 | + * @return string |
|
1151 | 1151 | */ |
1152 | 1152 | static function prep_required( $required = array() ){ |
1153 | 1153 | // make sure required is an array |
@@ -1198,8 +1198,8 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | /** |
1200 | 1200 | * _load_system_dropdowns |
1201 | - * @param array $QFI |
|
1202 | - * @return array |
|
1201 | + * @param EE_Question_Form_Input $QFI |
|
1202 | + * @return EE_Question_Form_Input |
|
1203 | 1203 | */ |
1204 | 1204 | private static function _load_system_dropdowns( $QFI ){ |
1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | * @param string $nonce_action - if using nonces |
1491 | 1491 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1493 | - * @return void |
|
1493 | + * @return string |
|
1494 | 1494 | */ |
1495 | 1495 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1496 | 1496 | $btn = ''; |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EEH_HTML |
|
5 | - * |
|
3 | + * |
|
4 | + * Class EEH_HTML |
|
5 | + * |
|
6 | 6 | * Sometimes when writing PHP you need to generate some standard HTML, |
7 | 7 | * but either not enough to warrant creating a template file, |
8 | 8 | * or the amount of PHP conditionals and/or loops peppered throughout the HTML |
9 | 9 | * just make it really ugly and difficult to read. |
10 | 10 | * This class simply adds a bunch of methods for generating basic HTML tags. |
11 | 11 | * Most of the methods have the same name as the HTML tag they generate, and most have the same set of parameters. |
12 | - * |
|
13 | - * @package Event Espresso |
|
14 | - * @subpackage core |
|
15 | - * @author Brent Christensen |
|
16 | - * @since $VID:$ |
|
17 | - * |
|
18 | - */ |
|
12 | + * |
|
13 | + * @package Event Espresso |
|
14 | + * @subpackage core |
|
15 | + * @author Brent Christensen |
|
16 | + * @since $VID:$ |
|
17 | + * |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | class EEH_HTML { |
21 | 21 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_HTML ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_HTML) { |
|
45 | 45 | self::$_instance = new EEH_HTML(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | $other_attributes = '', |
103 | 103 | $force_close = false |
104 | 104 | ) { |
105 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
106 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
107 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
108 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
109 | - $html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>'; |
|
110 | - $html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag ) . $content : ''; |
|
111 | - $indent = ! empty( $content ) || $force_close ? TRUE : FALSE; |
|
112 | - $html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : ''; |
|
105 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
106 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
107 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
108 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
109 | + $html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>'; |
|
110 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : ''; |
|
111 | + $indent = ! empty($content) || $force_close ? TRUE : FALSE; |
|
112 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
113 | 113 | return $html; |
114 | 114 | } |
115 | 115 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @param bool $indent |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) { |
|
129 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) { |
|
130 | 130 | $comment = ''; |
131 | - if ( $id ) { |
|
132 | - $comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag ); |
|
133 | - } else if ( $class ) { |
|
134 | - $comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag ); |
|
131 | + if ($id) { |
|
132 | + $comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag); |
|
133 | + } else if ($class) { |
|
134 | + $comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag); |
|
135 | 135 | } |
136 | 136 | $html = $indent ? EEH_HTML::nl( -1, $tag ) : ''; |
137 | - $html .= '</' . $tag . '>' . $comment; |
|
137 | + $html .= '</'.$tag.'>'.$comment; |
|
138 | 138 | return $html; |
139 | 139 | } |
140 | 140 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
157 | - return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes ); |
|
156 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
157 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param string $class - html class attribute |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public static function divx( $id = '', $class = '' ) { |
|
171 | - return EEH_HTML::_close_tag( 'div', $id, $class ); |
|
170 | + public static function divx($id = '', $class = '') { |
|
171 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
188 | - return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
187 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
188 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
205 | - return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
204 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
205 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
222 | - return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
221 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
222 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
239 | - return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
238 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
239 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
256 | - return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
255 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
256 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
273 | - return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
272 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
273 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
290 | - return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
289 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
290 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
306 | - return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes ); |
|
305 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') { |
|
306 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | * @param string $class - html class attribute |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function ulx( $id = '', $class = '' ) { |
|
320 | - return EEH_HTML::_close_tag( 'ul', $id, $class ); |
|
319 | + public static function ulx($id = '', $class = '') { |
|
320 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
338 | - return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes ); |
|
337 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
338 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * @param string $class - html class attribute |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public static function lix( $id = '', $class = '' ) { |
|
352 | - return EEH_HTML::_close_tag( 'li', $id, $class ); |
|
351 | + public static function lix($id = '', $class = '') { |
|
352 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
369 | - return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes ); |
|
368 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
369 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $class - html class attribute |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public static function tablex( $id = '', $class = '' ) { |
|
382 | - return EEH_HTML::_close_tag( 'table', $id, $class ); |
|
381 | + public static function tablex($id = '', $class = '') { |
|
382 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
399 | - return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes ); |
|
398 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
399 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $class - html class attribute |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public static function theadx( $id = '', $class = '' ) { |
|
412 | - return EEH_HTML::_close_tag( 'thead', $id, $class ); |
|
411 | + public static function theadx($id = '', $class = '') { |
|
412 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
429 | - return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes ); |
|
428 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
429 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $class - html class attribute |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public static function tbodyx( $id = '', $class = '' ) { |
|
442 | - return EEH_HTML::_close_tag( 'tbody', $id, $class ); |
|
441 | + public static function tbodyx($id = '', $class = '') { |
|
442 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
459 | - return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes ); |
|
458 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
459 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | * @param string $class - html class attribute |
469 | 469 | * @return string |
470 | 470 | */ |
471 | - public static function trx( $id = '', $class = '' ) { |
|
472 | - return EEH_HTML::_close_tag( 'tr', $id, $class ); |
|
471 | + public static function trx($id = '', $class = '') { |
|
472 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
489 | - return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes ); |
|
488 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
489 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $class - html class attribute |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function thx( $id = '', $class = '' ) { |
|
502 | - return EEH_HTML::_close_tag( 'th', $id, $class ); |
|
501 | + public static function thx($id = '', $class = '') { |
|
502 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
519 | - return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes ); |
|
518 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
519 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $class - html class attribute |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public static function tdx( $id = '', $class = '' ) { |
|
532 | - return EEH_HTML::_close_tag( 'td', $id, $class ); |
|
531 | + public static function tdx($id = '', $class = '') { |
|
532 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * @param int $colspan |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - public static function no_row( $content = '', $colspan = 2 ) { |
|
546 | + public static function no_row($content = '', $colspan = 2) { |
|
547 | 547 | return EEH_HTML::tr( |
548 | - EEH_HTML::td( $content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"' ), |
|
549 | - '', '', 'padding:0; border:none;' |
|
548 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'), |
|
549 | + '', '', 'padding:0; border:none;' |
|
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
567 | 567 | * @return string |
568 | 568 | */ |
569 | - public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
570 | - $link_text = ! empty( $link_text ) ? $link_text : $href; |
|
571 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
572 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
573 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
574 | - $attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : ''; |
|
575 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
576 | - return '<a href="' . $href . '" ' . $attributes . '>' . $link_text . '</a>'; |
|
569 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
570 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
571 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
572 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
573 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
574 | + $attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : ''; |
|
575 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
576 | + return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>'; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
@@ -590,14 +590,14 @@ discard block |
||
590 | 590 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
594 | - $attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : ''; |
|
595 | - $attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : ''; |
|
596 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
597 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
598 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
599 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
600 | - return '<img' . $attributes . '/>'; |
|
593 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
594 | + $attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : ''; |
|
595 | + $attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : ''; |
|
596 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
597 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
598 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
599 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
600 | + return '<img'.$attributes.'/>'; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
616 | 616 | * @return string |
617 | 617 | */ |
618 | - protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
619 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
620 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
621 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
622 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
623 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
618 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
619 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
620 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
621 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
622 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
623 | + return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>'; |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
640 | - return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes ); |
|
639 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
640 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
657 | - return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes ); |
|
656 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
657 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
671 | 671 | * @return string |
672 | 672 | */ |
673 | - public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
674 | - return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes ); |
|
673 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
674 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | * @param string $comment |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function comment( $comment = '' ) { |
|
687 | - return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
686 | + public static function comment($comment = '') { |
|
687 | + return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : ''; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -695,8 +695,8 @@ discard block |
||
695 | 695 | * @param int $nmbr - the number of line breaks to return |
696 | 696 | * @return string |
697 | 697 | */ |
698 | - public static function br( $nmbr = 1 ) { |
|
699 | - return str_repeat( '<br />', $nmbr ); |
|
698 | + public static function br($nmbr = 1) { |
|
699 | + return str_repeat('<br />', $nmbr); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | * @param int $nmbr - the number of non-breaking spaces to return |
708 | 708 | * @return string |
709 | 709 | */ |
710 | - public static function nbsp( $nmbr = 1 ) { |
|
711 | - return str_repeat( ' ', $nmbr ); |
|
710 | + public static function nbsp($nmbr = 1) { |
|
711 | + return str_repeat(' ', $nmbr); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -722,9 +722,9 @@ discard block |
||
722 | 722 | * @param string $id |
723 | 723 | * @return string |
724 | 724 | */ |
725 | - public static function sanitize_id( $id = '' ) { |
|
726 | - $key = str_replace( ' ', '-', trim( $id ) ); |
|
727 | - return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key ); |
|
725 | + public static function sanitize_id($id = '') { |
|
726 | + $key = str_replace(' ', '-', trim($id)); |
|
727 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | * @param string $tag |
737 | 737 | * @return string - newline character plus # of indents passed (can be + or -) |
738 | 738 | */ |
739 | - public static function nl( $indent = 0, $tag = 'none' ) { |
|
739 | + public static function nl($indent = 0, $tag = 'none') { |
|
740 | 740 | $html = "\n"; |
741 | - EEH_HTML::indent( $indent, $tag ); |
|
742 | - for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) { |
|
741 | + EEH_HTML::indent($indent, $tag); |
|
742 | + for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) { |
|
743 | 743 | $html .= "\t"; |
744 | 744 | } |
745 | 745 | return $html; |
@@ -754,17 +754,17 @@ discard block |
||
754 | 754 | * @param int $indent can be negative to decrease the indentation level |
755 | 755 | * @param string $tag |
756 | 756 | */ |
757 | - public static function indent( $indent, $tag = 'none' ){ |
|
757 | + public static function indent($indent, $tag = 'none') { |
|
758 | 758 | static $default_indentation = FALSE; |
759 | - if ( ! $default_indentation ) { |
|
759 | + if ( ! $default_indentation) { |
|
760 | 760 | EEH_HTML::_set_default_indentation(); |
761 | 761 | $default_indentation = TRUE; |
762 | 762 | } |
763 | - if ( ! isset( EEH_HTML::$_indent[ $tag ] )) { |
|
764 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
763 | + if ( ! isset(EEH_HTML::$_indent[$tag])) { |
|
764 | + EEH_HTML::$_indent[$tag] = 0; |
|
765 | 765 | } |
766 | - EEH_HTML::$_indent[ $tag ] += (int)$indent; |
|
767 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
766 | + EEH_HTML::$_indent[$tag] += (int) $indent; |
|
767 | + EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0; |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * @global array $allowedtags |
811 | 811 | * @return array |
812 | 812 | */ |
813 | - public static function get_simple_tags(){ |
|
813 | + public static function get_simple_tags() { |
|
814 | 814 | global $allowedtags; |
815 | 815 | $tags_we_allow = $allowedtags; |
816 | - $tags_we_allow['ol']=array(); |
|
817 | - $tags_we_allow['ul']=array(); |
|
818 | - $tags_we_allow['li']=array(); |
|
819 | - $tags_we_allow['br']=array(); |
|
820 | - $tags_we_allow['p']=array(); |
|
821 | - return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow ); |
|
816 | + $tags_we_allow['ol'] = array(); |
|
817 | + $tags_we_allow['ul'] = array(); |
|
818 | + $tags_we_allow['li'] = array(); |
|
819 | + $tags_we_allow['br'] = array(); |
|
820 | + $tags_we_allow['p'] = array(); |
|
821 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @version $Revision 0.1 $ |
36 | 36 | */ |
37 | 37 | class EEH_Inflector{ |
38 | - // ------ CLASS METHODS ------ // |
|
39 | - // ---- Public methods ---- // |
|
40 | - // {{{ pluralize() |
|
38 | + // ------ CLASS METHODS ------ // |
|
39 | + // ---- Public methods ---- // |
|
40 | + // {{{ pluralize() |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Just calls self::pluralize and strtolower on $word and returns it |
@@ -51,319 +51,319 @@ discard block |
||
51 | 51 | static function singularize_and_upper( $word ) { |
52 | 52 | return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) ); |
53 | 53 | } |
54 | - /** |
|
55 | - * Pluralizes English nouns. |
|
56 | - * |
|
57 | - * @access public |
|
58 | - * @static |
|
59 | - * @param string $word English noun to pluralize |
|
60 | - * @return string Plural noun |
|
61 | - */ |
|
62 | - static function pluralize($word){ |
|
63 | - $plural = array( |
|
64 | - '/(quiz)$/i' => '\1zes', |
|
65 | - '/^(ox)$/i' => '\1en', |
|
66 | - '/([m|l])ouse$/i' => '\1ice', |
|
67 | - '/(matr|vert|ind)ix|ex$/i' => '\1ices', |
|
68 | - '/(x|ch|ss|sh)$/i' => '\1es', |
|
69 | - '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
70 | - '/([^aeiouy]|qu)y$/i' => '\1ies', |
|
71 | - '/(hive)$/i' => '\1s', |
|
72 | - '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', |
|
73 | - '/sis$/i' => 'ses', |
|
74 | - '/([ti])um$/i' => '\1a', |
|
75 | - '/(buffal|tomat)o$/i' => '\1oes', |
|
76 | - '/(bu)s$/i' => '\1ses', |
|
77 | - '/(alias|status)/i' => '\1es', |
|
78 | - '/(octop|vir)us$/i' => '\1i', |
|
79 | - '/(ax|test)is$/i' => '\1es', |
|
80 | - '/s$/i' => 's', |
|
81 | - '/$/' => 's'); |
|
82 | - |
|
83 | - $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
84 | - |
|
85 | - $irregular = array( |
|
86 | - 'person' => 'people', |
|
87 | - 'man' => 'men', |
|
88 | - 'child' => 'children', |
|
89 | - 'sex' => 'sexes', |
|
90 | - 'move' => 'moves'); |
|
91 | - |
|
92 | - $lowercased_word = strtolower($word); |
|
93 | - |
|
94 | - foreach($uncountable as $_uncountable){ |
|
95 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
54 | + /** |
|
55 | + * Pluralizes English nouns. |
|
56 | + * |
|
57 | + * @access public |
|
58 | + * @static |
|
59 | + * @param string $word English noun to pluralize |
|
60 | + * @return string Plural noun |
|
61 | + */ |
|
62 | + static function pluralize($word){ |
|
63 | + $plural = array( |
|
64 | + '/(quiz)$/i' => '\1zes', |
|
65 | + '/^(ox)$/i' => '\1en', |
|
66 | + '/([m|l])ouse$/i' => '\1ice', |
|
67 | + '/(matr|vert|ind)ix|ex$/i' => '\1ices', |
|
68 | + '/(x|ch|ss|sh)$/i' => '\1es', |
|
69 | + '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
70 | + '/([^aeiouy]|qu)y$/i' => '\1ies', |
|
71 | + '/(hive)$/i' => '\1s', |
|
72 | + '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', |
|
73 | + '/sis$/i' => 'ses', |
|
74 | + '/([ti])um$/i' => '\1a', |
|
75 | + '/(buffal|tomat)o$/i' => '\1oes', |
|
76 | + '/(bu)s$/i' => '\1ses', |
|
77 | + '/(alias|status)/i' => '\1es', |
|
78 | + '/(octop|vir)us$/i' => '\1i', |
|
79 | + '/(ax|test)is$/i' => '\1es', |
|
80 | + '/s$/i' => 's', |
|
81 | + '/$/' => 's'); |
|
82 | + |
|
83 | + $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
84 | + |
|
85 | + $irregular = array( |
|
86 | + 'person' => 'people', |
|
87 | + 'man' => 'men', |
|
88 | + 'child' => 'children', |
|
89 | + 'sex' => 'sexes', |
|
90 | + 'move' => 'moves'); |
|
91 | + |
|
92 | + $lowercased_word = strtolower($word); |
|
93 | + |
|
94 | + foreach($uncountable as $_uncountable){ |
|
95 | + if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
96 | 96 | ! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){ |
97 | - return $word; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - foreach($irregular as $_plural => $_singular){ |
|
102 | - if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){ |
|
103 | - return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - foreach($plural as $rule => $replacement){ |
|
108 | - if(preg_match($rule, $word)){ |
|
109 | - return preg_replace($rule, $replacement, $word); |
|
110 | - } |
|
111 | - } |
|
112 | - return false; |
|
113 | - } |
|
114 | - |
|
115 | - // }}} |
|
116 | - // {{{ singularize() |
|
117 | - |
|
118 | - /** |
|
119 | - * Singularizes English nouns. |
|
120 | - * |
|
121 | - * @access public |
|
122 | - * @static |
|
123 | - * @param string $word English noun to singularize |
|
124 | - * @return string Singular noun. |
|
125 | - */ |
|
126 | - static function singularize($word){ |
|
127 | - $singular = array( |
|
128 | - '/(quiz)zes$/i' => '\1', |
|
129 | - '/(matr)ices$/i' => '\1ix', |
|
130 | - '/(vert|ind)ices$/i' => '\1ex', |
|
131 | - '/^(ox)en/i' => '\1', |
|
132 | - '/(alias|status)es$/i' => '\1', |
|
133 | - '/([octop|vir])i$/i' => '\1us', |
|
134 | - '/(cris|ax|test)es$/i' => '\1is', |
|
135 | - '/(shoe)s$/i' => '\1', |
|
136 | - '/(o)es$/i' => '\1', |
|
137 | - '/(bus)es$/i' => '\1', |
|
138 | - '/([m|l])ice$/i' => '\1ouse', |
|
139 | - '/(x|ch|ss|sh)es$/i' => '\1', |
|
140 | - '/(m)ovies$/i' => '\1ovie', |
|
141 | - '/(s)eries$/i' => '\1eries', |
|
142 | - '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
143 | - '/([lr])ves$/i' => '\1f', |
|
144 | - '/(tive)s$/i' => '\1', |
|
145 | - '/(hive)s$/i' => '\1', |
|
146 | - '/([^f])ves$/i' => '\1fe', |
|
147 | - '/(^analy)ses$/i' => '\1sis', |
|
148 | - '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', |
|
149 | - '/([ti])a$/i' => '\1um', |
|
150 | - '/(n)ews$/i' => '\1ews', |
|
151 | - '/s$/i' => '', |
|
152 | - ); |
|
153 | - |
|
154 | - $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
155 | - |
|
156 | - $irregular = array( |
|
157 | - 'person' => 'people', |
|
158 | - 'man' => 'men', |
|
159 | - 'child' => 'children', |
|
160 | - 'sex' => 'sexes', |
|
161 | - 'move' => 'moves'); |
|
162 | - |
|
163 | - $lowercased_word = strtolower($word); |
|
164 | - foreach($uncountable as $_uncountable){ |
|
165 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){ |
|
166 | - return $word; |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - foreach($irregular as $_plural => $_singular){ |
|
171 | - if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){ |
|
172 | - return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - foreach($singular as $rule => $replacement){ |
|
177 | - if(preg_match($rule, $word)){ |
|
178 | - return preg_replace($rule, $replacement, $word); |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - return $word; |
|
183 | - } |
|
184 | - |
|
185 | - // }}} |
|
186 | - // {{{ titleize() |
|
187 | - |
|
188 | - /** |
|
189 | - * Converts an underscored or CamelCase word into a English |
|
190 | - * sentence. |
|
191 | - * |
|
192 | - * The titleize static function converts text like "WelcomePage", |
|
193 | - * "welcome_page" or "welcome page" to this "Welcome |
|
194 | - * Page". |
|
195 | - * If second parameter is set to 'first' it will only |
|
196 | - * capitalize the first character of the title. |
|
197 | - * |
|
198 | - * @access public |
|
199 | - * @static |
|
200 | - * @param string $word Word to format as tile |
|
201 | - * @param string $uppercase If set to 'first' it will only uppercase the |
|
202 | - * first character. Otherwise it will uppercase all |
|
203 | - * the words in the title. |
|
204 | - * @return string Text formatted as title |
|
205 | - */ |
|
206 | - static function titleize($word, $uppercase = ''){ |
|
207 | - $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords'; |
|
208 | - return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word))); |
|
209 | - } |
|
210 | - |
|
211 | - // }}} |
|
212 | - // {{{ camelize() |
|
213 | - |
|
214 | - /** |
|
215 | - * Returns given word as CamelCased |
|
216 | - * |
|
217 | - * Converts a word like "send_email" to "SendEmail". It |
|
218 | - * will remove non alphanumeric character from the word, so |
|
219 | - * "who's online" will be converted to "WhoSOnline" |
|
220 | - * |
|
221 | - * @access public |
|
222 | - * @static |
|
223 | - * @see variablize |
|
224 | - * @param string $word Word to convert to camel case |
|
225 | - * @return string UpperCamelCasedWord |
|
226 | - */ |
|
227 | - static function camelize($word){ |
|
228 | - return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); |
|
229 | - } |
|
230 | - |
|
231 | - // }}} |
|
232 | - // {{{ underscore() |
|
233 | - |
|
234 | - /** |
|
235 | - * Converts a word "into_it_s_underscored_version" |
|
236 | - * |
|
237 | - * Convert any "CamelCased" or "ordinary Word" into an |
|
238 | - * "underscored_word". |
|
239 | - * |
|
240 | - * This can be really useful for creating friendly URLs. |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @static |
|
244 | - * @param string $word Word to underscore |
|
245 | - * @return string Underscored word |
|
246 | - */ |
|
247 | - static function underscore($word){ |
|
248 | - return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word)))); |
|
249 | - } |
|
250 | - |
|
251 | - // }}} |
|
252 | - // {{{ humanize() |
|
253 | - |
|
254 | - /** |
|
255 | - * Returns a human-readable string from $word |
|
256 | - * |
|
257 | - * Returns a human-readable string from $word, by replacing |
|
258 | - * underscores with a space, and by upper-casing the initial |
|
259 | - * character by default. |
|
260 | - * |
|
261 | - * If you need to uppercase all the words you just have to |
|
262 | - * pass 'all' as a second parameter. |
|
263 | - * |
|
264 | - * @access public |
|
265 | - * @static |
|
266 | - * @param string $word String to "humanize" |
|
267 | - * @param string $uppercase If set to 'all' it will uppercase all the words |
|
268 | - * instead of just the first one. |
|
269 | - * @return string Human-readable word |
|
270 | - */ |
|
271 | - static function humanize($word, $uppercase = ''){ |
|
97 | + return $word; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + foreach($irregular as $_plural => $_singular){ |
|
102 | + if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){ |
|
103 | + return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + foreach($plural as $rule => $replacement){ |
|
108 | + if(preg_match($rule, $word)){ |
|
109 | + return preg_replace($rule, $replacement, $word); |
|
110 | + } |
|
111 | + } |
|
112 | + return false; |
|
113 | + } |
|
114 | + |
|
115 | + // }}} |
|
116 | + // {{{ singularize() |
|
117 | + |
|
118 | + /** |
|
119 | + * Singularizes English nouns. |
|
120 | + * |
|
121 | + * @access public |
|
122 | + * @static |
|
123 | + * @param string $word English noun to singularize |
|
124 | + * @return string Singular noun. |
|
125 | + */ |
|
126 | + static function singularize($word){ |
|
127 | + $singular = array( |
|
128 | + '/(quiz)zes$/i' => '\1', |
|
129 | + '/(matr)ices$/i' => '\1ix', |
|
130 | + '/(vert|ind)ices$/i' => '\1ex', |
|
131 | + '/^(ox)en/i' => '\1', |
|
132 | + '/(alias|status)es$/i' => '\1', |
|
133 | + '/([octop|vir])i$/i' => '\1us', |
|
134 | + '/(cris|ax|test)es$/i' => '\1is', |
|
135 | + '/(shoe)s$/i' => '\1', |
|
136 | + '/(o)es$/i' => '\1', |
|
137 | + '/(bus)es$/i' => '\1', |
|
138 | + '/([m|l])ice$/i' => '\1ouse', |
|
139 | + '/(x|ch|ss|sh)es$/i' => '\1', |
|
140 | + '/(m)ovies$/i' => '\1ovie', |
|
141 | + '/(s)eries$/i' => '\1eries', |
|
142 | + '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
143 | + '/([lr])ves$/i' => '\1f', |
|
144 | + '/(tive)s$/i' => '\1', |
|
145 | + '/(hive)s$/i' => '\1', |
|
146 | + '/([^f])ves$/i' => '\1fe', |
|
147 | + '/(^analy)ses$/i' => '\1sis', |
|
148 | + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', |
|
149 | + '/([ti])a$/i' => '\1um', |
|
150 | + '/(n)ews$/i' => '\1ews', |
|
151 | + '/s$/i' => '', |
|
152 | + ); |
|
153 | + |
|
154 | + $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
155 | + |
|
156 | + $irregular = array( |
|
157 | + 'person' => 'people', |
|
158 | + 'man' => 'men', |
|
159 | + 'child' => 'children', |
|
160 | + 'sex' => 'sexes', |
|
161 | + 'move' => 'moves'); |
|
162 | + |
|
163 | + $lowercased_word = strtolower($word); |
|
164 | + foreach($uncountable as $_uncountable){ |
|
165 | + if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){ |
|
166 | + return $word; |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + foreach($irregular as $_plural => $_singular){ |
|
171 | + if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){ |
|
172 | + return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + foreach($singular as $rule => $replacement){ |
|
177 | + if(preg_match($rule, $word)){ |
|
178 | + return preg_replace($rule, $replacement, $word); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + return $word; |
|
183 | + } |
|
184 | + |
|
185 | + // }}} |
|
186 | + // {{{ titleize() |
|
187 | + |
|
188 | + /** |
|
189 | + * Converts an underscored or CamelCase word into a English |
|
190 | + * sentence. |
|
191 | + * |
|
192 | + * The titleize static function converts text like "WelcomePage", |
|
193 | + * "welcome_page" or "welcome page" to this "Welcome |
|
194 | + * Page". |
|
195 | + * If second parameter is set to 'first' it will only |
|
196 | + * capitalize the first character of the title. |
|
197 | + * |
|
198 | + * @access public |
|
199 | + * @static |
|
200 | + * @param string $word Word to format as tile |
|
201 | + * @param string $uppercase If set to 'first' it will only uppercase the |
|
202 | + * first character. Otherwise it will uppercase all |
|
203 | + * the words in the title. |
|
204 | + * @return string Text formatted as title |
|
205 | + */ |
|
206 | + static function titleize($word, $uppercase = ''){ |
|
207 | + $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords'; |
|
208 | + return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word))); |
|
209 | + } |
|
210 | + |
|
211 | + // }}} |
|
212 | + // {{{ camelize() |
|
213 | + |
|
214 | + /** |
|
215 | + * Returns given word as CamelCased |
|
216 | + * |
|
217 | + * Converts a word like "send_email" to "SendEmail". It |
|
218 | + * will remove non alphanumeric character from the word, so |
|
219 | + * "who's online" will be converted to "WhoSOnline" |
|
220 | + * |
|
221 | + * @access public |
|
222 | + * @static |
|
223 | + * @see variablize |
|
224 | + * @param string $word Word to convert to camel case |
|
225 | + * @return string UpperCamelCasedWord |
|
226 | + */ |
|
227 | + static function camelize($word){ |
|
228 | + return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); |
|
229 | + } |
|
230 | + |
|
231 | + // }}} |
|
232 | + // {{{ underscore() |
|
233 | + |
|
234 | + /** |
|
235 | + * Converts a word "into_it_s_underscored_version" |
|
236 | + * |
|
237 | + * Convert any "CamelCased" or "ordinary Word" into an |
|
238 | + * "underscored_word". |
|
239 | + * |
|
240 | + * This can be really useful for creating friendly URLs. |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @static |
|
244 | + * @param string $word Word to underscore |
|
245 | + * @return string Underscored word |
|
246 | + */ |
|
247 | + static function underscore($word){ |
|
248 | + return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word)))); |
|
249 | + } |
|
250 | + |
|
251 | + // }}} |
|
252 | + // {{{ humanize() |
|
253 | + |
|
254 | + /** |
|
255 | + * Returns a human-readable string from $word |
|
256 | + * |
|
257 | + * Returns a human-readable string from $word, by replacing |
|
258 | + * underscores with a space, and by upper-casing the initial |
|
259 | + * character by default. |
|
260 | + * |
|
261 | + * If you need to uppercase all the words you just have to |
|
262 | + * pass 'all' as a second parameter. |
|
263 | + * |
|
264 | + * @access public |
|
265 | + * @static |
|
266 | + * @param string $word String to "humanize" |
|
267 | + * @param string $uppercase If set to 'all' it will uppercase all the words |
|
268 | + * instead of just the first one. |
|
269 | + * @return string Human-readable word |
|
270 | + */ |
|
271 | + static function humanize($word, $uppercase = ''){ |
|
272 | 272 | //make special exceptions for acronyms |
273 | 273 | $word = str_replace('wp_', 'WP_', $word ); |
274 | - $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst'; |
|
275 | - return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word))); |
|
276 | - } |
|
277 | - |
|
278 | - // }}} |
|
279 | - // {{{ variablize() |
|
280 | - |
|
281 | - /** |
|
282 | - * Same as camelize but first char is underscored |
|
283 | - * |
|
284 | - * Converts a word like "send_email" to "sendEmail". It |
|
285 | - * will remove non alphanumeric character from the word, so |
|
286 | - * "who's online" will be converted to "whoSOnline" |
|
287 | - * |
|
288 | - * @access public |
|
289 | - * @static |
|
290 | - * @see camelize |
|
291 | - * @param string $word Word to lowerCamelCase |
|
292 | - * @return string Returns a lowerCamelCasedWord |
|
293 | - */ |
|
294 | - static function variablize($word){ |
|
295 | - $word = EEH_Inflector::camelize($word); |
|
296 | - return strtolower($word[0]) . substr($word, 1); |
|
297 | - } |
|
298 | - |
|
299 | - // }}} |
|
300 | - // {{{ tableize() |
|
301 | - |
|
302 | - /** |
|
303 | - * Converts a class name to its table name according to rails |
|
304 | - * naming conventions. |
|
305 | - * |
|
306 | - * Converts "Person" to "people" |
|
307 | - * |
|
308 | - * @access public |
|
309 | - * @static |
|
310 | - * @see classify |
|
311 | - * @param string $class_name Class name for getting related table_name. |
|
312 | - * @return string plural_table_name |
|
313 | - */ |
|
314 | - static function tableize($class_name){ |
|
315 | - return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name)); |
|
316 | - } |
|
317 | - |
|
318 | - // }}} |
|
319 | - // {{{ classify() |
|
320 | - |
|
321 | - /** |
|
322 | - * Converts a table name to its class name according to rails |
|
323 | - * naming conventions. |
|
324 | - * |
|
325 | - * Converts "people" to "Person" |
|
326 | - * |
|
327 | - * @access public |
|
328 | - * @static |
|
329 | - * @see tableize |
|
330 | - * @param string $table_name Table name for getting related ClassName. |
|
331 | - * @return string SingularClassName |
|
332 | - */ |
|
333 | - static function classify($table_name){ |
|
334 | - return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name)); |
|
335 | - } |
|
336 | - |
|
337 | - // }}} |
|
338 | - // {{{ ordinalize() |
|
339 | - |
|
340 | - /** |
|
341 | - * Converts number to its ordinal English form. |
|
342 | - * |
|
343 | - * This method converts 13 to 13th, 2 to 2nd ... |
|
344 | - * |
|
345 | - * @access public |
|
346 | - * @static |
|
347 | - * @param integer $number Number to get its ordinal value |
|
348 | - * @return string Ordinal representation of given string. |
|
349 | - */ |
|
350 | - static function ordinalize($number){ |
|
351 | - if(in_array(($number % 100), range(11, 13))){ |
|
352 | - return $number . 'th'; |
|
353 | - }else{ |
|
354 | - switch(($number % 10)){ |
|
355 | - case 1: |
|
356 | - return $number . 'st'; |
|
357 | - break; |
|
358 | - case 2: |
|
359 | - return $number . 'nd'; |
|
360 | - break; |
|
361 | - case 3: |
|
362 | - return $number . 'rd'; |
|
363 | - default: |
|
364 | - return $number . 'th'; |
|
365 | - break; |
|
366 | - } |
|
367 | - } |
|
368 | - } |
|
274 | + $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst'; |
|
275 | + return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word))); |
|
276 | + } |
|
277 | + |
|
278 | + // }}} |
|
279 | + // {{{ variablize() |
|
280 | + |
|
281 | + /** |
|
282 | + * Same as camelize but first char is underscored |
|
283 | + * |
|
284 | + * Converts a word like "send_email" to "sendEmail". It |
|
285 | + * will remove non alphanumeric character from the word, so |
|
286 | + * "who's online" will be converted to "whoSOnline" |
|
287 | + * |
|
288 | + * @access public |
|
289 | + * @static |
|
290 | + * @see camelize |
|
291 | + * @param string $word Word to lowerCamelCase |
|
292 | + * @return string Returns a lowerCamelCasedWord |
|
293 | + */ |
|
294 | + static function variablize($word){ |
|
295 | + $word = EEH_Inflector::camelize($word); |
|
296 | + return strtolower($word[0]) . substr($word, 1); |
|
297 | + } |
|
298 | + |
|
299 | + // }}} |
|
300 | + // {{{ tableize() |
|
301 | + |
|
302 | + /** |
|
303 | + * Converts a class name to its table name according to rails |
|
304 | + * naming conventions. |
|
305 | + * |
|
306 | + * Converts "Person" to "people" |
|
307 | + * |
|
308 | + * @access public |
|
309 | + * @static |
|
310 | + * @see classify |
|
311 | + * @param string $class_name Class name for getting related table_name. |
|
312 | + * @return string plural_table_name |
|
313 | + */ |
|
314 | + static function tableize($class_name){ |
|
315 | + return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name)); |
|
316 | + } |
|
317 | + |
|
318 | + // }}} |
|
319 | + // {{{ classify() |
|
320 | + |
|
321 | + /** |
|
322 | + * Converts a table name to its class name according to rails |
|
323 | + * naming conventions. |
|
324 | + * |
|
325 | + * Converts "people" to "Person" |
|
326 | + * |
|
327 | + * @access public |
|
328 | + * @static |
|
329 | + * @see tableize |
|
330 | + * @param string $table_name Table name for getting related ClassName. |
|
331 | + * @return string SingularClassName |
|
332 | + */ |
|
333 | + static function classify($table_name){ |
|
334 | + return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name)); |
|
335 | + } |
|
336 | + |
|
337 | + // }}} |
|
338 | + // {{{ ordinalize() |
|
339 | + |
|
340 | + /** |
|
341 | + * Converts number to its ordinal English form. |
|
342 | + * |
|
343 | + * This method converts 13 to 13th, 2 to 2nd ... |
|
344 | + * |
|
345 | + * @access public |
|
346 | + * @static |
|
347 | + * @param integer $number Number to get its ordinal value |
|
348 | + * @return string Ordinal representation of given string. |
|
349 | + */ |
|
350 | + static function ordinalize($number){ |
|
351 | + if(in_array(($number % 100), range(11, 13))){ |
|
352 | + return $number . 'th'; |
|
353 | + }else{ |
|
354 | + switch(($number % 10)){ |
|
355 | + case 1: |
|
356 | + return $number . 'st'; |
|
357 | + break; |
|
358 | + case 2: |
|
359 | + return $number . 'nd'; |
|
360 | + break; |
|
361 | + case 3: |
|
362 | + return $number . 'rd'; |
|
363 | + default: |
|
364 | + return $number . 'th'; |
|
365 | + break; |
|
366 | + } |
|
367 | + } |
|
368 | + } |
|
369 | 369 | } |
370 | 370 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | // +----------------------------------------------------------------------+ |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @since 0.1 |
35 | 35 | * @version $Revision 0.1 $ |
36 | 36 | */ |
37 | -class EEH_Inflector{ |
|
37 | +class EEH_Inflector { |
|
38 | 38 | // ------ CLASS METHODS ------ // |
39 | 39 | // ---- Public methods ---- // |
40 | 40 | // {{{ pluralize() |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | * @param string $word |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - static function pluralize_and_lower( $word ){ |
|
48 | - return strtolower( self::pluralize( $word ) ); |
|
47 | + static function pluralize_and_lower($word) { |
|
48 | + return strtolower(self::pluralize($word)); |
|
49 | 49 | } |
50 | 50 | |
51 | - static function singularize_and_upper( $word ) { |
|
52 | - return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) ); |
|
51 | + static function singularize_and_upper($word) { |
|
52 | + return str_replace(' ', '_', self::humanize(self::singularize($word), 'all')); |
|
53 | 53 | } |
54 | 54 | /** |
55 | 55 | * Pluralizes English nouns. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $word English noun to pluralize |
60 | 60 | * @return string Plural noun |
61 | 61 | */ |
62 | - static function pluralize($word){ |
|
62 | + static function pluralize($word) { |
|
63 | 63 | $plural = array( |
64 | 64 | '/(quiz)$/i' => '\1zes', |
65 | 65 | '/^(ox)$/i' => '\1en', |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | |
92 | 92 | $lowercased_word = strtolower($word); |
93 | 93 | |
94 | - foreach($uncountable as $_uncountable){ |
|
95 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
96 | - ! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){ |
|
94 | + foreach ($uncountable as $_uncountable) { |
|
95 | + if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
96 | + ! ctype_alpha($lowercased_word[strlen($lowercased_word) - strlen($_uncountable)])) { |
|
97 | 97 | return $word; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - foreach($irregular as $_plural => $_singular){ |
|
102 | - if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){ |
|
103 | - return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
101 | + foreach ($irregular as $_plural => $_singular) { |
|
102 | + if (preg_match('/('.$_plural.')$/i', $word, $arr)) { |
|
103 | + return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - foreach($plural as $rule => $replacement){ |
|
108 | - if(preg_match($rule, $word)){ |
|
107 | + foreach ($plural as $rule => $replacement) { |
|
108 | + if (preg_match($rule, $word)) { |
|
109 | 109 | return preg_replace($rule, $replacement, $word); |
110 | 110 | } |
111 | 111 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $word English noun to singularize |
124 | 124 | * @return string Singular noun. |
125 | 125 | */ |
126 | - static function singularize($word){ |
|
126 | + static function singularize($word) { |
|
127 | 127 | $singular = array( |
128 | 128 | '/(quiz)zes$/i' => '\1', |
129 | 129 | '/(matr)ices$/i' => '\1ix', |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | 'move' => 'moves'); |
162 | 162 | |
163 | 163 | $lowercased_word = strtolower($word); |
164 | - foreach($uncountable as $_uncountable){ |
|
165 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){ |
|
164 | + foreach ($uncountable as $_uncountable) { |
|
165 | + if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) { |
|
166 | 166 | return $word; |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - foreach($irregular as $_plural => $_singular){ |
|
171 | - if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){ |
|
172 | - return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
170 | + foreach ($irregular as $_plural => $_singular) { |
|
171 | + if (preg_match('/('.$_singular.')$/i', $word, $arr)) { |
|
172 | + return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - foreach($singular as $rule => $replacement){ |
|
177 | - if(preg_match($rule, $word)){ |
|
176 | + foreach ($singular as $rule => $replacement) { |
|
177 | + if (preg_match($rule, $word)) { |
|
178 | 178 | return preg_replace($rule, $replacement, $word); |
179 | 179 | } |
180 | 180 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * the words in the title. |
204 | 204 | * @return string Text formatted as title |
205 | 205 | */ |
206 | - static function titleize($word, $uppercase = ''){ |
|
206 | + static function titleize($word, $uppercase = '') { |
|
207 | 207 | $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords'; |
208 | 208 | return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word))); |
209 | 209 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param string $word Word to convert to camel case |
225 | 225 | * @return string UpperCamelCasedWord |
226 | 226 | */ |
227 | - static function camelize($word){ |
|
227 | + static function camelize($word) { |
|
228 | 228 | return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); |
229 | 229 | } |
230 | 230 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param string $word Word to underscore |
245 | 245 | * @return string Underscored word |
246 | 246 | */ |
247 | - static function underscore($word){ |
|
247 | + static function underscore($word) { |
|
248 | 248 | return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word)))); |
249 | 249 | } |
250 | 250 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | * instead of just the first one. |
269 | 269 | * @return string Human-readable word |
270 | 270 | */ |
271 | - static function humanize($word, $uppercase = ''){ |
|
271 | + static function humanize($word, $uppercase = '') { |
|
272 | 272 | //make special exceptions for acronyms |
273 | - $word = str_replace('wp_', 'WP_', $word ); |
|
273 | + $word = str_replace('wp_', 'WP_', $word); |
|
274 | 274 | $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst'; |
275 | 275 | return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word))); |
276 | 276 | } |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @param string $word Word to lowerCamelCase |
292 | 292 | * @return string Returns a lowerCamelCasedWord |
293 | 293 | */ |
294 | - static function variablize($word){ |
|
294 | + static function variablize($word) { |
|
295 | 295 | $word = EEH_Inflector::camelize($word); |
296 | - return strtolower($word[0]) . substr($word, 1); |
|
296 | + return strtolower($word[0]).substr($word, 1); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | // }}} |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param string $class_name Class name for getting related table_name. |
312 | 312 | * @return string plural_table_name |
313 | 313 | */ |
314 | - static function tableize($class_name){ |
|
314 | + static function tableize($class_name) { |
|
315 | 315 | return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name)); |
316 | 316 | } |
317 | 317 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @param string $table_name Table name for getting related ClassName. |
331 | 331 | * @return string SingularClassName |
332 | 332 | */ |
333 | - static function classify($table_name){ |
|
333 | + static function classify($table_name) { |
|
334 | 334 | return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name)); |
335 | 335 | } |
336 | 336 | |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | * @param integer $number Number to get its ordinal value |
348 | 348 | * @return string Ordinal representation of given string. |
349 | 349 | */ |
350 | - static function ordinalize($number){ |
|
351 | - if(in_array(($number % 100), range(11, 13))){ |
|
352 | - return $number . 'th'; |
|
353 | - }else{ |
|
354 | - switch(($number % 10)){ |
|
350 | + static function ordinalize($number) { |
|
351 | + if (in_array(($number % 100), range(11, 13))) { |
|
352 | + return $number.'th'; |
|
353 | + } else { |
|
354 | + switch (($number % 10)) { |
|
355 | 355 | case 1: |
356 | - return $number . 'st'; |
|
356 | + return $number.'st'; |
|
357 | 357 | break; |
358 | 358 | case 2: |
359 | - return $number . 'nd'; |
|
359 | + return $number.'nd'; |
|
360 | 360 | break; |
361 | 361 | case 3: |
362 | - return $number . 'rd'; |
|
362 | + return $number.'rd'; |
|
363 | 363 | default: |
364 | - return $number . 'th'; |
|
364 | + return $number.'th'; |
|
365 | 365 | break; |
366 | 366 | } |
367 | 367 | } |
@@ -350,7 +350,7 @@ |
||
350 | 350 | static function ordinalize($number){ |
351 | 351 | if(in_array(($number % 100), range(11, 13))){ |
352 | 352 | return $number . 'th'; |
353 | - }else{ |
|
353 | + } else{ |
|
354 | 354 | switch(($number % 10)){ |
355 | 355 | case 1: |
356 | 356 | return $number . 'st'; |
@@ -280,7 +280,7 @@ |
||
280 | 280 | $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
281 | 281 | if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
282 | 282 | $success = $pre_tax_subtotal->add_child_line_item($item); |
283 | - }else{ |
|
283 | + } else{ |
|
284 | 284 | return FALSE; |
285 | 285 | } |
286 | 286 | $total_line_item->recalculate_total_including_taxes(); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * EEH_Line_Item |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
41 | 41 | * @return boolean success |
42 | 42 | */ |
43 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
44 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
43 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
44 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
45 | 45 | $line_item = EE_Line_Item::new_instance(array( |
46 | 46 | 'LIN_name' => $name, |
47 | 47 | 'LIN_desc' => $description, |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | 'LIN_quantity' => $quantity, |
50 | 50 | 'LIN_percent' => null, |
51 | 51 | 'LIN_is_taxable' => $taxable, |
52 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
53 | - 'LIN_total' => floatval( $unit_price ) * intval( $quantity ), |
|
52 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
53 | + 'LIN_total' => floatval($unit_price) * intval($quantity), |
|
54 | 54 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
55 | 55 | 'LIN_code' => $code, |
56 | 56 | )); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $line_item, |
60 | 60 | $parent_line_item |
61 | 61 | ); |
62 | - return self::add_item( $parent_line_item, $line_item ); |
|
62 | + return self::add_item($parent_line_item, $line_item); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param boolean $taxable |
81 | 81 | * @return boolean success |
82 | 82 | */ |
83 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
83 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
84 | 84 | $line_item = EE_Line_Item::new_instance(array( |
85 | 85 | 'LIN_name' => $name, |
86 | 86 | 'LIN_desc' => $description, |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | 'LIN_percent' => $percentage_amount, |
89 | 89 | 'LIN_quantity' => NULL, |
90 | 90 | 'LIN_is_taxable' => $taxable, |
91 | - 'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )), |
|
91 | + 'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)), |
|
92 | 92 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
93 | 93 | 'LIN_parent' => $parent_line_item->ID() |
94 | 94 | )); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
97 | 97 | $line_item |
98 | 98 | ); |
99 | - return self::add_item( $parent_line_item, $line_item ); |
|
99 | + return self::add_item($parent_line_item, $line_item); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * @return \EE_Line_Item |
118 | 118 | * @throws \EE_Error |
119 | 119 | */ |
120 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
121 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
122 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
120 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
121 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
122 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
123 | 123 | } |
124 | 124 | // either increment the qty for an existing ticket |
125 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
125 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
126 | 126 | // or add a new one |
127 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
128 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
127 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
128 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
129 | 129 | } |
130 | 130 | $total_line_item->recalculate_total_including_taxes(); |
131 | 131 | return $line_item; |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | * @return \EE_Line_Item |
142 | 142 | * @throws \EE_Error |
143 | 143 | */ |
144 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
144 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
145 | 145 | $line_item = null; |
146 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
147 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
148 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
149 | - if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) { |
|
146 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
147 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
148 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
149 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) { |
|
150 | 150 | $line_item = $ticket_line_item; |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | - if ( $line_item instanceof EE_Line_Item ) { |
|
156 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
155 | + if ($line_item instanceof EE_Line_Item) { |
|
156 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
157 | 157 | return $line_item; |
158 | 158 | } |
159 | 159 | return null; |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | * @param int $qty |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
170 | - if( ! $line_item->is_percent() ) { |
|
169 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
170 | + if ( ! $line_item->is_percent()) { |
|
171 | 171 | $qty += $line_item->quantity(); |
172 | - $line_item->set_quantity( $qty ); |
|
173 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
172 | + $line_item->set_quantity($qty); |
|
173 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
174 | 174 | } |
175 | - foreach( $line_item->children() as $child ) { |
|
176 | - if( $child->is_sub_line_item() ) { |
|
177 | - EEH_Line_Item::update_quantity( $child, $line_item->quantity() ); |
|
175 | + foreach ($line_item->children() as $child) { |
|
176 | + if ($child->is_sub_line_item()) { |
|
177 | + EEH_Line_Item::update_quantity($child, $line_item->quantity()); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | * @param EE_Line_Item $line_item |
186 | 186 | * @param int $new_quantity |
187 | 187 | */ |
188 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
189 | - if( ! $line_item->is_percent() ) { |
|
190 | - $line_item->set_quantity( $new_quantity ); |
|
191 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
188 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
189 | + if ( ! $line_item->is_percent()) { |
|
190 | + $line_item->set_quantity($new_quantity); |
|
191 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
192 | 192 | } |
193 | - foreach( $line_item->children() as $child ) { |
|
194 | - if( $child->is_sub_line_item() ) { |
|
195 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
193 | + foreach ($line_item->children() as $child) { |
|
194 | + if ($child->is_sub_line_item()) { |
|
195 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
@@ -207,45 +207,45 @@ discard block |
||
207 | 207 | * @return \EE_Line_Item |
208 | 208 | * @throws \EE_Error |
209 | 209 | */ |
210 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
210 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
211 | 211 | $datetimes = $ticket->datetimes(); |
212 | - $first_datetime = reset( $datetimes ); |
|
213 | - if( $first_datetime instanceof EE_Datetime && |
|
214 | - $first_datetime->event() instanceof EE_Event ) { |
|
212 | + $first_datetime = reset($datetimes); |
|
213 | + if ($first_datetime instanceof EE_Datetime && |
|
214 | + $first_datetime->event() instanceof EE_Event) { |
|
215 | 215 | $first_datetime_name = $first_datetime->event()->name(); |
216 | 216 | } else { |
217 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
217 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
218 | 218 | } |
219 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
219 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
220 | 220 | // get event subtotal line |
221 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
222 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
223 | - throw new EE_Error( sprintf( __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
221 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
222 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
223 | + throw new EE_Error(sprintf(__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
224 | 224 | } |
225 | 225 | // add $ticket to cart |
226 | - $line_item = EE_Line_Item::new_instance( array( |
|
226 | + $line_item = EE_Line_Item::new_instance(array( |
|
227 | 227 | 'LIN_name' => $ticket->name(), |
228 | - 'LIN_desc' => $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event, |
|
228 | + 'LIN_desc' => $ticket->description() != '' ? $ticket->description().' '.$event : $event, |
|
229 | 229 | 'LIN_unit_price' => $ticket->price(), |
230 | 230 | 'LIN_quantity' => $qty, |
231 | 231 | 'LIN_is_taxable' => $ticket->taxable(), |
232 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
232 | + 'LIN_order' => count($events_sub_total->children()), |
|
233 | 233 | 'LIN_total' => $ticket->price() * $qty, |
234 | 234 | 'LIN_type' => EEM_Line_Item::type_line_item, |
235 | 235 | 'OBJ_ID' => $ticket->ID(), |
236 | 236 | 'OBJ_type' => 'Ticket' |
237 | - ) ); |
|
237 | + )); |
|
238 | 238 | $line_item = apply_filters( |
239 | 239 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
240 | 240 | $line_item |
241 | 241 | ); |
242 | - $events_sub_total->add_child_line_item( $line_item ); |
|
242 | + $events_sub_total->add_child_line_item($line_item); |
|
243 | 243 | //now add the sub-line items |
244 | 244 | $running_total_for_ticket = 0; |
245 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
245 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
246 | 246 | $sign = $price->is_discount() ? -1 : 1; |
247 | 247 | $price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty; |
248 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
248 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
249 | 249 | 'LIN_name' => $price->name(), |
250 | 250 | 'LIN_desc' => $price->desc(), |
251 | 251 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
256 | 256 | 'OBJ_ID' => $price->ID(), |
257 | 257 | 'OBJ_type' => 'Price' |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | $sub_line_item = apply_filters( |
260 | 260 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
261 | 261 | $sub_line_item |
262 | 262 | ); |
263 | - if ( $price->is_percent() ) { |
|
264 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
263 | + if ($price->is_percent()) { |
|
264 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
265 | 265 | } else { |
266 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
266 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
267 | 267 | } |
268 | 268 | $running_total_for_ticket += $price_total; |
269 | - $line_item->add_child_line_item( $sub_line_item ); |
|
269 | + $line_item->add_child_line_item($sub_line_item); |
|
270 | 270 | } |
271 | 271 | return $line_item; |
272 | 272 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param EE_Line_Item $item to be added |
285 | 285 | * @return boolean |
286 | 286 | */ |
287 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
288 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
289 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
287 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
288 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
289 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
290 | 290 | $success = $pre_tax_subtotal->add_child_line_item($item); |
291 | - }else{ |
|
291 | + } else { |
|
292 | 292 | return FALSE; |
293 | 293 | } |
294 | 294 | $total_line_item->recalculate_total_including_taxes(); |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
303 | 303 | * @return \EE_Line_Item |
304 | 304 | */ |
305 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
306 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
307 | - return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item ); |
|
305 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
306 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
307 | + return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
315 | 315 | * @return \EE_Line_Item |
316 | 316 | */ |
317 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
318 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
319 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
317 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
318 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
319 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @param EE_Transaction $transaction |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
331 | - if( $transaction ){ |
|
330 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
331 | + if ($transaction) { |
|
332 | 332 | /** @type EEM_Transaction $EEM_Transaction */ |
333 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
334 | - $transaction = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
335 | - $line_item->set_TXN_ID( $transaction ); |
|
333 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
334 | + $transaction = $EEM_Transaction->ensure_is_ID($transaction); |
|
335 | + $line_item->set_TXN_ID($transaction); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param EE_Transaction $transaction |
346 | 346 | * @return \EE_Line_Item of type total |
347 | 347 | */ |
348 | - public static function create_total_line_item( $transaction = NULL ){ |
|
349 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
348 | + public static function create_total_line_item($transaction = NULL) { |
|
349 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
350 | 350 | 'LIN_code' => 'total', |
351 | 351 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
352 | 352 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
357 | 357 | $total_line_item |
358 | 358 | ); |
359 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
360 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
361 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
359 | + self::set_TXN_ID($total_line_item, $transaction); |
|
360 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
361 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
362 | 362 | return $total_line_item; |
363 | 363 | } |
364 | 364 | |
@@ -370,19 +370,19 @@ discard block |
||
370 | 370 | * @param EE_Transaction $transaction |
371 | 371 | * @return EE_Line_Item |
372 | 372 | */ |
373 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
374 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
373 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
374 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
375 | 375 | 'LIN_code' => 'pre-tax-subtotal', |
376 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
376 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
377 | 377 | 'LIN_type' => EEM_Line_Item::type_sub_total |
378 | - ) ); |
|
378 | + )); |
|
379 | 379 | $pre_tax_line_item = apply_filters( |
380 | 380 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
381 | 381 | $pre_tax_line_item |
382 | 382 | ); |
383 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
384 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
385 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
383 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
384 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
385 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
386 | 386 | return $pre_tax_line_item; |
387 | 387 | } |
388 | 388 | |
@@ -395,21 +395,21 @@ discard block |
||
395 | 395 | * @param EE_Transaction $transaction |
396 | 396 | * @return EE_Line_Item |
397 | 397 | */ |
398 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
398 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
399 | 399 | $tax_line_item = EE_Line_Item::new_instance(array( |
400 | 400 | 'LIN_code' => 'taxes', |
401 | 401 | 'LIN_name' => __('Taxes', 'event_espresso'), |
402 | 402 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
403 | - 'LIN_order' => 1000,//this should always come last |
|
403 | + 'LIN_order' => 1000, //this should always come last |
|
404 | 404 | )); |
405 | 405 | $tax_line_item = apply_filters( |
406 | 406 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
407 | 407 | $tax_line_item |
408 | 408 | ); |
409 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
410 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
409 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
410 | + $total_line_item->add_child_line_item($tax_line_item); |
|
411 | 411 | //and lastly, add the actual taxes |
412 | - self::apply_taxes( $total_line_item ); |
|
412 | + self::apply_taxes($total_line_item); |
|
413 | 413 | return $tax_line_item; |
414 | 414 | } |
415 | 415 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | * @param EE_Event $event |
423 | 423 | * @return EE_Line_Item |
424 | 424 | */ |
425 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
425 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
426 | 426 | $event_line_item = EE_Line_Item::new_instance(array( |
427 | - 'LIN_code' => self::get_event_code( $event ), |
|
428 | - 'LIN_name' => self::get_event_name( $event ), |
|
429 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
427 | + 'LIN_code' => self::get_event_code($event), |
|
428 | + 'LIN_name' => self::get_event_name($event), |
|
429 | + 'LIN_desc' => self::get_event_desc($event), |
|
430 | 430 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
431 | 431 | 'OBJ_type' => 'Event', |
432 | 432 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
436 | 436 | $event_line_item |
437 | 437 | ); |
438 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
439 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
438 | + self::set_TXN_ID($event_line_item, $transaction); |
|
439 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
440 | 440 | return $event_line_item; |
441 | 441 | } |
442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * @param EE_Event $event |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public static function get_event_code( $event ) { |
|
449 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
448 | + public static function get_event_code($event) { |
|
449 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param EE_Event $event |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public static function get_event_name( $event ) { |
|
458 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
457 | + public static function get_event_name($event) { |
|
458 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param EE_Event $event |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public static function get_event_desc( $event ) { |
|
466 | + public static function get_event_desc($event) { |
|
467 | 467 | return $event instanceof EE_Event ? $event->short_description() : ''; |
468 | 468 | } |
469 | 469 | |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * @throws \EE_Error |
478 | 478 | * @return EE_Line_Item |
479 | 479 | */ |
480 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
480 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
481 | 481 | $first_datetime = $ticket->first_datetime(); |
482 | - if( ! $first_datetime instanceof EE_Datetime ){ |
|
483 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) ); |
|
482 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
483 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())); |
|
484 | 484 | } |
485 | 485 | $event = $first_datetime->event(); |
486 | - if ( ! $event instanceof EE_Event ) { |
|
487 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) ); |
|
486 | + if ( ! $event instanceof EE_Event) { |
|
487 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID())); |
|
488 | 488 | } |
489 | - return EEH_Line_Item::get_event_line_item( $grand_total, $event ); |
|
489 | + return EEH_Line_Item::get_event_line_item($grand_total, $event); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -495,31 +495,31 @@ discard block |
||
495 | 495 | * @param EE_Event $event |
496 | 496 | * @return EE_Line_Item for the event subtotal which is a child of $grand_total |
497 | 497 | */ |
498 | - public static function get_event_line_item( EE_Line_Item $grand_total, $event ) { |
|
498 | + public static function get_event_line_item(EE_Line_Item $grand_total, $event) { |
|
499 | 499 | /** @type EE_Event $event */ |
500 | - $event = EEM_Event::instance()->ensure_is_obj( $event, true ); |
|
500 | + $event = EEM_Event::instance()->ensure_is_obj($event, true); |
|
501 | 501 | $event_line_item = NULL; |
502 | 502 | $found = false; |
503 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
503 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
504 | 504 | // default event subtotal, we should only ever find this the first time this method is called |
505 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
505 | + if ( ! $event_line_item->OBJ_ID()) { |
|
506 | 506 | // let's use this! but first... set the event details |
507 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
507 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
508 | 508 | $found = true; |
509 | 509 | break; |
510 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
510 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
511 | 511 | // found existing line item for this event in the cart, so break out of loop and use this one |
512 | 512 | $found = true; |
513 | 513 | break; |
514 | 514 | } |
515 | 515 | } |
516 | - if ( ! $found ) { |
|
516 | + if ( ! $found) { |
|
517 | 517 | //there is no event sub-total yet, so add it |
518 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
518 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
519 | 519 | // create a new "event" subtotal below that |
520 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
520 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
521 | 521 | // and set the event details |
522 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
522 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
523 | 523 | } |
524 | 524 | return $event_line_item; |
525 | 525 | } |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | * @param EE_Transaction $transaction |
534 | 534 | * @return EE_Line_Item |
535 | 535 | */ |
536 | - public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){ |
|
537 | - if ( $event instanceof EE_Event ) { |
|
538 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
539 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
540 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
541 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
536 | + public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) { |
|
537 | + if ($event instanceof EE_Event) { |
|
538 | + $event_line_item->set_code(self::get_event_code($event)); |
|
539 | + $event_line_item->set_name(self::get_event_name($event)); |
|
540 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
541 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
542 | 542 | } |
543 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
543 | + self::set_TXN_ID($event_line_item, $transaction); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | |
@@ -551,19 +551,19 @@ discard block |
||
551 | 551 | * any old taxes are removed |
552 | 552 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
553 | 553 | */ |
554 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
554 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
555 | 555 | /** @type EEM_Price $EEM_Price */ |
556 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
556 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
557 | 557 | // get array of taxes via Price Model |
558 | 558 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
559 | - ksort( $ordered_taxes ); |
|
560 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
559 | + ksort($ordered_taxes); |
|
560 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
561 | 561 | //just to be safe, remove its old tax line items |
562 | 562 | $taxes_line_item->delete_children_line_items(); |
563 | 563 | //loop thru taxes |
564 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
565 | - foreach ( $taxes as $tax ) { |
|
566 | - if ( $tax instanceof EE_Price ) { |
|
564 | + foreach ($ordered_taxes as $order => $taxes) { |
|
565 | + foreach ($taxes as $tax) { |
|
566 | + if ($tax instanceof EE_Price) { |
|
567 | 567 | $tax_line_item = EE_Line_Item::new_instance( |
568 | 568 | array( |
569 | 569 | 'LIN_name' => $tax->name(), |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
582 | 582 | $tax_line_item |
583 | 583 | ); |
584 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
584 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | } |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
597 | 597 | * @return float |
598 | 598 | */ |
599 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
600 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
601 | - if( ! $taxes_subtotal->children()){ |
|
602 | - self::apply_taxes( $total_line_item ); |
|
599 | + public static function ensure_taxes_applied($total_line_item) { |
|
600 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
601 | + if ( ! $taxes_subtotal->children()) { |
|
602 | + self::apply_taxes($total_line_item); |
|
603 | 603 | } |
604 | 604 | return $taxes_subtotal->total(); |
605 | 605 | } |
@@ -612,16 +612,16 @@ discard block |
||
612 | 612 | * @param EE_Line_Item $parent_line_item |
613 | 613 | * @return bool |
614 | 614 | */ |
615 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
615 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
616 | 616 | $deleted = 0; |
617 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
618 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
619 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
620 | - if ( $child_line_item->ID() ) { |
|
617 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
618 | + if ($child_line_item instanceof EE_Line_Item) { |
|
619 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
620 | + if ($child_line_item->ID()) { |
|
621 | 621 | $child_line_item->delete(); |
622 | - unset( $child_line_item ); |
|
622 | + unset($child_line_item); |
|
623 | 623 | } else { |
624 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
624 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
625 | 625 | } |
626 | 626 | $deleted++; |
627 | 627 | } |
@@ -643,25 +643,25 @@ discard block |
||
643 | 643 | * @param array|bool|string $line_item_codes |
644 | 644 | * @return int number of items successfully removed |
645 | 645 | */ |
646 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
646 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
647 | 647 | |
648 | - if( $total_line_item->type() != EEM_Line_Item::type_total ){ |
|
649 | - EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __( 'This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso' ), '4.6.18' ); |
|
648 | + if ($total_line_item->type() != EEM_Line_Item::type_total) { |
|
649 | + EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18'); |
|
650 | 650 | } |
651 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
651 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
652 | 652 | |
653 | 653 | // check if only a single line_item_id was passed |
654 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
654 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
655 | 655 | // place single line_item_id in an array to appear as multiple line_item_ids |
656 | - $line_item_codes = array ( $line_item_codes ); |
|
656 | + $line_item_codes = array($line_item_codes); |
|
657 | 657 | } |
658 | 658 | $removals = 0; |
659 | 659 | // cycle thru line_item_ids |
660 | - foreach ( $line_item_codes as $line_item_id ) { |
|
660 | + foreach ($line_item_codes as $line_item_id) { |
|
661 | 661 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
662 | 662 | } |
663 | 663 | |
664 | - if ( $removals > 0 ) { |
|
664 | + if ($removals > 0) { |
|
665 | 665 | $total_line_item->recalculate_taxes_and_tax_total(); |
666 | 666 | return $removals; |
667 | 667 | } else { |
@@ -684,32 +684,32 @@ discard block |
||
684 | 684 | * $amount will be added onto it; otherwise will simply set the taxes to match $amount |
685 | 685 | * @return EE_Line_Item the new tax line item created |
686 | 686 | */ |
687 | - public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){ |
|
688 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
687 | + public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false) { |
|
688 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
689 | 689 | $taxable_total = $total_line_item->taxable_total(); |
690 | 690 | |
691 | - if( $add_to_existing_line_item ) { |
|
692 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | - EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
691 | + if ($add_to_existing_line_item) { |
|
692 | + $new_tax = $tax_subtotal->get_child_line_item($code); |
|
693 | + EEM_Line_Item::instance()->delete(array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID()))); |
|
694 | 694 | } else { |
695 | 695 | $new_tax = null; |
696 | 696 | $tax_subtotal->delete_children_line_items(); |
697 | 697 | } |
698 | - if( $new_tax ) { |
|
699 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | - $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
698 | + if ($new_tax) { |
|
699 | + $new_tax->set_total($new_tax->total() + $amount); |
|
700 | + $new_tax->set_percent($taxable_total ? ($new_tax->total()) / $taxable_total * 100 : 0); |
|
701 | 701 | } else { |
702 | 702 | //no existing tax item. Create it |
703 | - $new_tax = EE_Line_Item::new_instance( array( |
|
703 | + $new_tax = EE_Line_Item::new_instance(array( |
|
704 | 704 | 'TXN_ID' => $total_line_item->TXN_ID(), |
705 | - 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
|
705 | + 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
|
706 | 706 | 'LIN_desc' => $description ? $description : '', |
707 | - 'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0, |
|
707 | + 'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0, |
|
708 | 708 | 'LIN_total' => $amount, |
709 | 709 | 'LIN_parent' => $tax_subtotal->ID(), |
710 | 710 | 'LIN_type' => EEM_Line_Item::type_tax, |
711 | 711 | 'LIN_code' => $code |
712 | - ) ); |
|
712 | + )); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | $new_tax = apply_filters( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $total_line_item |
719 | 719 | ); |
720 | 720 | $new_tax->save(); |
721 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
721 | + $tax_subtotal->set_total($new_tax->total()); |
|
722 | 722 | $tax_subtotal->save(); |
723 | 723 | $total_line_item->recalculate_total_including_taxes(); |
724 | 724 | return $new_tax; |
@@ -734,17 +734,17 @@ discard block |
||
734 | 734 | * it will be whitelisted (ie, except from becoming taxable) |
735 | 735 | * @param boolean $taxable |
736 | 736 | */ |
737 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ) { |
|
738 | - if( $code_substring_for_whitelist !== null ) { |
|
739 | - $whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false; |
|
737 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null) { |
|
738 | + if ($code_substring_for_whitelist !== null) { |
|
739 | + $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false; |
|
740 | 740 | } else { |
741 | 741 | $whitelisted = false; |
742 | 742 | } |
743 | - if( $line_item->is_line_item() && ! $whitelisted ) { |
|
744 | - $line_item->set_is_taxable( $taxable ); |
|
743 | + if ($line_item->is_line_item() && ! $whitelisted) { |
|
744 | + $line_item->set_is_taxable($taxable); |
|
745 | 745 | } |
746 | - foreach( $line_item->children() as $child_line_item ) { |
|
747 | - EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist ); |
|
746 | + foreach ($line_item->children() as $child_line_item) { |
|
747 | + EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist); |
|
748 | 748 | } |
749 | 749 | } |
750 | 750 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
758 | 758 | * @return EE_Line_Item[] |
759 | 759 | */ |
760 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
761 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
760 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
761 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | * @param string $obj_type |
772 | 772 | * @return EE_Line_Item[] |
773 | 773 | */ |
774 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
775 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type ); |
|
774 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
775 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
785 | 785 | * @return EE_Line_Item[] |
786 | 786 | */ |
787 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
788 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
787 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
788 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | * @param string $obj_type |
799 | 799 | * @return EE_Line_Item[] |
800 | 800 | */ |
801 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
802 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
801 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
802 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
811 | 811 | * @return EE_Line_Item[] |
812 | 812 | */ |
813 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
814 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
813 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
814 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
823 | 823 | * @return EE_Line_Item[] |
824 | 824 | */ |
825 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
826 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
825 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
826 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | * @param string $line_item_type one of the EEM_Line_Item constants |
837 | 837 | * @return EE_Line_Item[] |
838 | 838 | */ |
839 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
840 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
839 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
840 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | |
@@ -850,15 +850,15 @@ discard block |
||
850 | 850 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
851 | 851 | * @return EE_Line_Item[] |
852 | 852 | */ |
853 | - protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
|
853 | + protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) { |
|
854 | 854 | $objects = array(); |
855 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
856 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
857 | - if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) { |
|
855 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
856 | + if ($child_line_item instanceof EE_Line_Item) { |
|
857 | + if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) { |
|
858 | 858 | $objects[] = $child_line_item; |
859 | 859 | } else { |
860 | 860 | //go-through-all-its children looking for more matches |
861 | - $objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type )); |
|
861 | + $objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type)); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | } |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | * @param array $OBJ_IDs array of OBJ_IDs |
877 | 877 | * @return EE_Line_Item[] |
878 | 878 | */ |
879 | - public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
|
880 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
879 | + public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) { |
|
880 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | * @param array $OBJ_IDs array of OBJ_IDs |
891 | 891 | * @return EE_Line_Item[] |
892 | 892 | */ |
893 | - protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) { |
|
893 | + protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) { |
|
894 | 894 | $objects = array(); |
895 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
896 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
897 | - if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) { |
|
895 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
896 | + if ($child_line_item instanceof EE_Line_Item) { |
|
897 | + if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) { |
|
898 | 898 | $objects[] = $child_line_item; |
899 | 899 | } else { |
900 | 900 | //go-through-all-its children looking for more matches |
901 | - $objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs )); |
|
901 | + $objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs)); |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | } |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @param string $type like one of the EEM_Line_Item::type_* |
917 | 917 | * @return EE_Line_Item |
918 | 918 | */ |
919 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
920 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
919 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
920 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | * @param string $code any value used for LIN_code |
931 | 931 | * @return EE_Line_Item |
932 | 932 | */ |
933 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
934 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
933 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
934 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | |
@@ -944,15 +944,15 @@ discard block |
||
944 | 944 | * @param string $value any value stored in $search_field |
945 | 945 | * @return EE_Line_Item |
946 | 946 | */ |
947 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
948 | - foreach( $parent_line_item->children() as $child ){ |
|
949 | - if ( $child->get( $search_field ) == $value ){ |
|
947 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
948 | + foreach ($parent_line_item->children() as $child) { |
|
949 | + if ($child->get($search_field) == $value) { |
|
950 | 950 | return $child; |
951 | 951 | } |
952 | 952 | } |
953 | - foreach( $parent_line_item->children() as $child ){ |
|
954 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
955 | - if ( $descendant_found ){ |
|
953 | + foreach ($parent_line_item->children() as $child) { |
|
954 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
955 | + if ($descendant_found) { |
|
956 | 956 | return $descendant_found; |
957 | 957 | } |
958 | 958 | } |
@@ -968,22 +968,22 @@ discard block |
||
968 | 968 | * @param int $indentation |
969 | 969 | * @return void |
970 | 970 | */ |
971 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
971 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
972 | 972 | echo "\n<br />"; |
973 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
973 | + for ($i = 0; $i < $indentation; $i++) { |
|
974 | 974 | echo " - "; |
975 | 975 | } |
976 | - if( $line_item->is_percent() ) { |
|
977 | - $breakdown = $line_item->percent() . '%'; |
|
976 | + if ($line_item->is_percent()) { |
|
977 | + $breakdown = $line_item->percent().'%'; |
|
978 | 978 | } else { |
979 | - $breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity(); |
|
979 | + $breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity(); |
|
980 | 980 | } |
981 | - echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")"; |
|
982 | - if( $line_item->is_taxable() ){ |
|
981 | + echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")"; |
|
982 | + if ($line_item->is_taxable()) { |
|
983 | 983 | echo " * taxable"; |
984 | 984 | } |
985 | - if( $line_item->children() ){ |
|
986 | - foreach($line_item->children() as $child){ |
|
985 | + if ($line_item->children()) { |
|
986 | + foreach ($line_item->children() as $child) { |
|
987 | 987 | self::visualize($child, $indentation + 1); |
988 | 988 | } |
989 | 989 | } |
@@ -1024,88 +1024,88 @@ discard block |
||
1024 | 1024 | * is theirs, which can be done with |
1025 | 1025 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
1026 | 1026 | */ |
1027 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
1027 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
1028 | 1028 | //init running grand total if not already |
1029 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
1030 | - $running_totals[ 'total' ] = 0; |
|
1029 | + if ( ! isset($running_totals['total'])) { |
|
1030 | + $running_totals['total'] = 0; |
|
1031 | 1031 | } |
1032 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
1033 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
1032 | + if ( ! isset($running_totals['taxable'])) { |
|
1033 | + $running_totals['taxable'] = array('total' => 0); |
|
1034 | 1034 | } |
1035 | - foreach ( $line_item->children() as $child_line_item ) { |
|
1036 | - switch ( $child_line_item->type() ) { |
|
1035 | + foreach ($line_item->children() as $child_line_item) { |
|
1036 | + switch ($child_line_item->type()) { |
|
1037 | 1037 | |
1038 | 1038 | case EEM_Line_Item::type_sub_total : |
1039 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
1039 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
1040 | 1040 | //combine arrays but preserve numeric keys |
1041 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
1042 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
1043 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
1041 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
1042 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
1043 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
1044 | 1044 | break; |
1045 | 1045 | |
1046 | 1046 | case EEM_Line_Item::type_tax_sub_total : |
1047 | 1047 | |
1048 | 1048 | //find how much the taxes percentage is |
1049 | - if ( $child_line_item->percent() != 0 ) { |
|
1049 | + if ($child_line_item->percent() != 0) { |
|
1050 | 1050 | $tax_percent_decimal = $child_line_item->percent() / 100; |
1051 | 1051 | } else { |
1052 | 1052 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
1053 | 1053 | } |
1054 | 1054 | //and apply to all the taxable totals, and add to the pretax totals |
1055 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1055 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1056 | 1056 | //"total" and "taxable" array key is an exception |
1057 | - if ( $line_item_id === 'taxable' ) { |
|
1057 | + if ($line_item_id === 'taxable') { |
|
1058 | 1058 | continue; |
1059 | 1059 | } |
1060 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1061 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1060 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1061 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1062 | 1062 | } |
1063 | 1063 | break; |
1064 | 1064 | |
1065 | 1065 | case EEM_Line_Item::type_line_item : |
1066 | 1066 | |
1067 | 1067 | // ticket line items or ???? |
1068 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1068 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1069 | 1069 | // kk it's a ticket |
1070 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1070 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1071 | 1071 | //huh? that shouldn't happen. |
1072 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1072 | + $running_totals['total'] += $child_line_item->total(); |
|
1073 | 1073 | } else { |
1074 | 1074 | //its not in our running totals yet. great. |
1075 | - if ( $child_line_item->is_taxable() ) { |
|
1075 | + if ($child_line_item->is_taxable()) { |
|
1076 | 1076 | $taxable_amount = $child_line_item->unit_price(); |
1077 | 1077 | } else { |
1078 | 1078 | $taxable_amount = 0; |
1079 | 1079 | } |
1080 | 1080 | // are we only calculating totals for some tickets? |
1081 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1082 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1083 | - $running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0; |
|
1084 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0; |
|
1081 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1082 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1083 | + $running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0; |
|
1084 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0; |
|
1085 | 1085 | } else { |
1086 | 1086 | $quantity = $child_line_item->quantity(); |
1087 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1088 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1087 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1088 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1089 | 1089 | } |
1090 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1091 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1090 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1091 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1092 | 1092 | } |
1093 | 1093 | } else { |
1094 | 1094 | // it's some other type of item added to the cart |
1095 | 1095 | // it should affect the running totals |
1096 | 1096 | // basically we want to convert it into a PERCENT modifier. Because |
1097 | 1097 | // more clearly affect all registration's final price equally |
1098 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1; |
|
1099 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1098 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1; |
|
1099 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1100 | 1100 | //the "taxable" array key is an exception |
1101 | - if ( $line_item_id === 'taxable' ) { |
|
1101 | + if ($line_item_id === 'taxable') { |
|
1102 | 1102 | continue; |
1103 | 1103 | } |
1104 | 1104 | // update the running totals |
1105 | 1105 | // yes this actually even works for the running grand total! |
1106 | - $running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total; |
|
1107 | - if ( $child_line_item->is_taxable() ) { |
|
1108 | - $running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1106 | + $running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total; |
|
1107 | + if ($child_line_item->is_taxable()) { |
|
1108 | + $running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | } |
@@ -1124,15 +1124,15 @@ discard block |
||
1124 | 1124 | * @param EE_Registration[] $registrations |
1125 | 1125 | * @return \EE_Line_Item |
1126 | 1126 | */ |
1127 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1128 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1129 | - foreach ( $line_item->children() as $child_li ) { |
|
1130 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1127 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1128 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1129 | + foreach ($line_item->children() as $child_li) { |
|
1130 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1131 | 1131 | } |
1132 | 1132 | //if this is the grand total line item, make sure the totals all add up |
1133 | 1133 | //(we could have duplicated this logic AS we copied the line items, but |
1134 | 1134 | //it seems DRYer this way) |
1135 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1135 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1136 | 1136 | $copy_li->recalculate_total_including_taxes(); |
1137 | 1137 | } |
1138 | 1138 | return $copy_li; |
@@ -1147,26 +1147,26 @@ discard block |
||
1147 | 1147 | * @return EE_Line_Item |
1148 | 1148 | * @param EE_Registration[] $registrations |
1149 | 1149 | */ |
1150 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1150 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1151 | 1151 | $new_li_fields = $line_item->model_field_array(); |
1152 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1152 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1153 | 1153 | $line_item->OBJ_type() === 'Ticket' |
1154 | 1154 | ) { |
1155 | 1155 | $count = 0; |
1156 | - foreach ( $registrations as $registration ) { |
|
1157 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1158 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1156 | + foreach ($registrations as $registration) { |
|
1157 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1158 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1159 | 1159 | ) { |
1160 | 1160 | $count++; |
1161 | 1161 | } |
1162 | 1162 | } |
1163 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1163 | + $new_li_fields['LIN_quantity'] = $count; |
|
1164 | 1164 | } |
1165 | 1165 | //don't set the total. We'll leave that up to the code that calculates it |
1166 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1167 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1168 | - unset( $new_li_fields[ 'LIN_total' ] ); |
|
1169 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1166 | + unset($new_li_fields['LIN_ID']); |
|
1167 | + unset($new_li_fields['LIN_parent']); |
|
1168 | + unset($new_li_fields['LIN_total']); |
|
1169 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | |
@@ -1178,19 +1178,19 @@ discard block |
||
1178 | 1178 | * @param EE_Line_Item $line_item |null |
1179 | 1179 | * @return \EE_Line_Item|null |
1180 | 1180 | */ |
1181 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1182 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1183 | - if ( $copied_li === null ) { |
|
1181 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1182 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1183 | + if ($copied_li === null) { |
|
1184 | 1184 | return null; |
1185 | 1185 | } |
1186 | 1186 | //if this is an event subtotal, we want to only include it if it |
1187 | 1187 | //has a non-zero total and at least one ticket line item child |
1188 | 1188 | $ticket_children = 0; |
1189 | - foreach ( $line_item->children() as $child_li ) { |
|
1190 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1191 | - if ( $child_li_copy !== null ) { |
|
1192 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1193 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1189 | + foreach ($line_item->children() as $child_li) { |
|
1190 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1191 | + if ($child_li_copy !== null) { |
|
1192 | + $copied_li->add_child_line_item($child_li_copy); |
|
1193 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1194 | 1194 | $child_li_copy->OBJ_type() === 'Ticket' |
1195 | 1195 | ) { |
1196 | 1196 | $ticket_children++; |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | } |
1200 | 1200 | //if this is an event subtotal with NO ticket children |
1201 | 1201 | //we basically want to ignore it |
1202 | - if ( $line_item->type() === EEM_Line_Item::type_sub_total && |
|
1202 | + if ($line_item->type() === EEM_Line_Item::type_sub_total && |
|
1203 | 1203 | $line_item->OBJ_type() === 'Event' && |
1204 | 1204 | $ticket_children === 0 && |
1205 | 1205 | $line_item->total() === 0 |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | * @param EE_Line_Item $line_item |
1218 | 1218 | * @return EE_Line_Item |
1219 | 1219 | */ |
1220 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1221 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1220 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1221 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1222 | 1222 | $line_item->OBJ_type() === 'Ticket' && |
1223 | 1223 | $line_item->quantity() == 0 |
1224 | 1224 | ) { |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | } |
1227 | 1227 | $new_li_fields = $line_item->model_field_array(); |
1228 | 1228 | //don't set the total. We'll leave that up to the code that calculates it |
1229 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1230 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1231 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1229 | + unset($new_li_fields['LIN_ID']); |
|
1230 | + unset($new_li_fields['LIN_parent']); |
|
1231 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1242,9 +1242,9 @@ discard block |
||
1242 | 1242 | * @param EE_Line_Item $total_line_item |
1243 | 1243 | * @return \EE_Line_Item |
1244 | 1244 | */ |
1245 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1246 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1247 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1245 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1246 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1247 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | |
@@ -1254,9 +1254,9 @@ discard block |
||
1254 | 1254 | * @param EE_Transaction $transaction |
1255 | 1255 | * @return \EE_Line_Item |
1256 | 1256 | */ |
1257 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1258 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1259 | - return self::create_total_line_item( $transaction ); |
|
1257 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1258 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1259 | + return self::create_total_line_item($transaction); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | |
@@ -1267,9 +1267,9 @@ discard block |
||
1267 | 1267 | * @param EE_Transaction $transaction |
1268 | 1268 | * @return \EE_Line_Item |
1269 | 1269 | */ |
1270 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1271 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1272 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1270 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1271 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1272 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | |
@@ -1280,9 +1280,9 @@ discard block |
||
1280 | 1280 | * @param EE_Transaction $transaction |
1281 | 1281 | * @return \EE_Line_Item |
1282 | 1282 | */ |
1283 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1284 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1285 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1283 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1284 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1285 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | * @param EE_Transaction $transaction |
1294 | 1294 | * @return \EE_Line_Item |
1295 | 1295 | */ |
1296 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1297 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1298 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1296 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1297 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1298 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | - * Given the grand total line item and a ticket, finds the event sub-total |
|
472 | - * line item the ticket's purchase should be added onto |
|
473 | - * |
|
474 | - * @access public |
|
475 | - * @param EE_Line_Item $grand_total the grand total line item |
|
476 | - * @param EE_Ticket $ticket |
|
477 | - * @throws \EE_Error |
|
478 | - * @return EE_Line_Item |
|
479 | - */ |
|
471 | + * Given the grand total line item and a ticket, finds the event sub-total |
|
472 | + * line item the ticket's purchase should be added onto |
|
473 | + * |
|
474 | + * @access public |
|
475 | + * @param EE_Line_Item $grand_total the grand total line item |
|
476 | + * @param EE_Ticket $ticket |
|
477 | + * @throws \EE_Error |
|
478 | + * @return EE_Line_Item |
|
479 | + */ |
|
480 | 480 | public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
481 | 481 | $first_datetime = $ticket->first_datetime(); |
482 | 482 | if( ! $first_datetime instanceof EE_Datetime ){ |
@@ -685,21 +685,21 @@ discard block |
||
685 | 685 | * @return EE_Line_Item the new tax line item created |
686 | 686 | */ |
687 | 687 | public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){ |
688 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
689 | - $taxable_total = $total_line_item->taxable_total(); |
|
690 | - |
|
691 | - if( $add_to_existing_line_item ) { |
|
692 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | - EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
694 | - } else { |
|
695 | - $new_tax = null; |
|
696 | - $tax_subtotal->delete_children_line_items(); |
|
697 | - } |
|
698 | - if( $new_tax ) { |
|
699 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | - $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
701 | - } else { |
|
702 | - //no existing tax item. Create it |
|
688 | + $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
689 | + $taxable_total = $total_line_item->taxable_total(); |
|
690 | + |
|
691 | + if( $add_to_existing_line_item ) { |
|
692 | + $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | + EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
694 | + } else { |
|
695 | + $new_tax = null; |
|
696 | + $tax_subtotal->delete_children_line_items(); |
|
697 | + } |
|
698 | + if( $new_tax ) { |
|
699 | + $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | + $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
701 | + } else { |
|
702 | + //no existing tax item. Create it |
|
703 | 703 | $new_tax = EE_Line_Item::new_instance( array( |
704 | 704 | 'TXN_ID' => $total_line_item->TXN_ID(), |
705 | 705 | 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
@@ -712,16 +712,16 @@ discard block |
||
712 | 712 | ) ); |
713 | 713 | } |
714 | 714 | |
715 | - $new_tax = apply_filters( |
|
715 | + $new_tax = apply_filters( |
|
716 | 716 | 'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal', |
717 | 717 | $new_tax, |
718 | 718 | $total_line_item |
719 | - ); |
|
720 | - $new_tax->save(); |
|
721 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
722 | - $tax_subtotal->save(); |
|
723 | - $total_line_item->recalculate_total_including_taxes(); |
|
724 | - return $new_tax; |
|
719 | + ); |
|
720 | + $new_tax->save(); |
|
721 | + $tax_subtotal->set_total( $new_tax->total() ); |
|
722 | + $tax_subtotal->save(); |
|
723 | + $total_line_item->recalculate_total_including_taxes(); |
|
724 | + return $new_tax; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * Deletes ALL children of the passed line item |
611 | 611 | * |
612 | 612 | * @param EE_Line_Item $parent_line_item |
613 | - * @return bool |
|
613 | + * @return integer |
|
614 | 614 | */ |
615 | 615 | public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
616 | 616 | $deleted = 0; |
@@ -848,6 +848,7 @@ discard block |
||
848 | 848 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
849 | 849 | * @param string $line_item_type one of the EEM_Line_Item constants |
850 | 850 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
851 | + * @param string $obj_type |
|
851 | 852 | * @return EE_Line_Item[] |
852 | 853 | */ |
853 | 854 | protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
@@ -873,7 +874,7 @@ discard block |
||
873 | 874 | * @uses EEH_Line_Item::_get_descendants_by_type_and_object_type() |
874 | 875 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
875 | 876 | * @param string $OBJ_type object type (like Event) |
876 | - * @param array $OBJ_IDs array of OBJ_IDs |
|
877 | + * @param string[] $OBJ_IDs array of OBJ_IDs |
|
877 | 878 | * @return EE_Line_Item[] |
878 | 879 | */ |
879 | 880 | public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
@@ -8,18 +8,18 @@ |
||
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
10 | 10 | /** |
11 | - * |
|
12 | - * Money helper class. |
|
13 | - * This class has helper methods that help with money related conversions and calculations. |
|
14 | - * |
|
15 | - * @since %VER% |
|
16 | - * |
|
17 | - * @package Event Espresso |
|
18 | - * @subpackage helpers |
|
19 | - * @author Darren Ethier |
|
20 | - * |
|
21 | - * ------------------------------------------------------------------------ |
|
22 | - */ |
|
11 | + * |
|
12 | + * Money helper class. |
|
13 | + * This class has helper methods that help with money related conversions and calculations. |
|
14 | + * |
|
15 | + * @since %VER% |
|
16 | + * |
|
17 | + * @package Event Espresso |
|
18 | + * @subpackage helpers |
|
19 | + * @author Darren Ethier |
|
20 | + * |
|
21 | + * ------------------------------------------------------------------------ |
|
22 | + */ |
|
23 | 23 | class EEH_Money extends EEH_Base { |
24 | 24 | |
25 | 25 |
@@ -6,7 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage helper |
8 | 8 | */ |
9 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | +} |
|
10 | 12 | /** |
11 | 13 | * |
12 | 14 | * Money helper class. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * ------------------------------------------------------------------------ |
22 | 22 | */ |
23 | -class EEH_Money extends EEH_Base { |
|
23 | +class EEH_Money extends EEH_Base { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @param int|string $incoming_value |
30 | 30 | * @return float |
31 | 31 | */ |
32 | - public static function convert_to_float_from_localized_money( $incoming_value ) { |
|
32 | + public static function convert_to_float_from_localized_money($incoming_value) { |
|
33 | 33 | //remove thousands separator |
34 | - $money_value = str_replace( EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value ); |
|
34 | + $money_value = str_replace(EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value); |
|
35 | 35 | |
36 | 36 | //replace decimal place with standard decimal. |
37 | - $money_value = str_replace( EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value ); |
|
37 | + $money_value = str_replace(EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value); |
|
38 | 38 | |
39 | 39 | //float it! and round to three decimal places |
40 | - $money_value = round ( (float) $money_value, 3 ); |
|
40 | + $money_value = round((float) $money_value, 3); |
|
41 | 41 | return $money_value; |
42 | 42 | } |
43 | 43 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * @throws \EE_Error |
58 | 58 | */ |
59 | 59 | |
60 | - public static function compare_floats( $float1, $float2, $operator='=' ) { |
|
60 | + public static function compare_floats($float1, $float2, $operator = '=') { |
|
61 | 61 | // Check numbers to 5 digits of precision |
62 | 62 | $epsilon = 0.00001; |
63 | 63 | |
64 | - $float1 = (float)$float1; |
|
65 | - $float2 = (float)$float2; |
|
64 | + $float1 = (float) $float1; |
|
65 | + $float2 = (float) $float2; |
|
66 | 66 | |
67 | 67 | switch ($operator) { |
68 | 68 | // equal |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | break; |
118 | 118 | default: |
119 | - throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) ); |
|
119 | + throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso')); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return false; |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public static function get_format_for_jqplot( $CNT_ISO = '') { |
|
134 | + public static function get_format_for_jqplot($CNT_ISO = '') { |
|
135 | 135 | //default format |
136 | 136 | $format = 'f'; |
137 | 137 | //if CNT_ISO passed lets try to get currency settings for it. |
138 | - $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null; |
|
138 | + $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
139 | 139 | //default currency settings for site if not set |
140 | - if ( ! $currency_config instanceof EE_Currency_Config ) { |
|
140 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
141 | 141 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | //first get the decimal place and number of places |
145 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
145 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
146 | 146 | |
147 | 147 | //currency symbol on right side. |
148 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
148 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
149 | 149 | return $format; |
150 | 150 | } |
151 | 151 | |
@@ -160,27 +160,27 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
|
163 | + public static function get_format_for_google_charts($CNT_ISO = '') { |
|
164 | 164 | //if CNT_ISO passed lets try to get currency settings for it. |
165 | - $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null; |
|
165 | + $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
166 | 166 | //default currency settings for site if not set |
167 | - if ( ! $currency_config instanceof EE_Currency_Config ) { |
|
167 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
168 | 168 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
169 | 169 | } |
170 | 170 | |
171 | - $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
|
171 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
172 | 172 | |
173 | 173 | //first get the decimal place and number of places |
174 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
174 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
175 | 175 | |
176 | 176 | //currency symbol on right side. |
177 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
177 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
178 | 178 | $formatterObject = array( |
179 | 179 | 'decimalSymbol' => $currency_config->dec_mrk, |
180 | 180 | 'groupingSymbol' => $currency_config->thsnds, |
181 | 181 | 'fractionDigits' => $currency_config->dec_plc, |
182 | 182 | ); |
183 | - if ( $currency_config->sign_b4 ) { |
|
183 | + if ($currency_config->sign_b4) { |
|
184 | 184 | $formatterObject['prefix'] = $currency_config->sign; |
185 | 185 | } else { |
186 | 186 | $formatterObject['suffix'] = $currency_config->sign; |
@@ -160,8 +160,9 @@ discard block |
||
160 | 160 | // first use WP locate_template to check for template in the current theme folder |
161 | 161 | $template_path = locate_template( $templates ); |
162 | 162 | |
163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
164 | - return TRUE; |
|
163 | + if ( $check_if_custom && !empty( $template_path ) ) { |
|
164 | + return TRUE; |
|
165 | + } |
|
165 | 166 | |
166 | 167 | // not in the theme |
167 | 168 | if ( empty( $template_path )) { |
@@ -364,11 +365,11 @@ discard block |
||
364 | 365 | if( $mny->sign_b4 ){ |
365 | 366 | if( $amount >= 0 ){ |
366 | 367 | $amount_formatted = $mny->sign . $amount_formatted; |
367 | - }else{ |
|
368 | + } else{ |
|
368 | 369 | $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
369 | 370 | } |
370 | 371 | |
371 | - }else{ |
|
372 | + } else{ |
|
372 | 373 | $amount_formatted = $amount_formatted . $mny->sign; |
373 | 374 | } |
374 | 375 | |
@@ -432,11 +433,13 @@ discard block |
||
432 | 433 | */ |
433 | 434 | public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
434 | 435 | |
435 | - if ( ! $page ) |
|
436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
436 | + if ( ! $page ) { |
|
437 | + $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
438 | + } |
|
437 | 439 | |
438 | - if ( ! $action ) |
|
439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
440 | + if ( ! $action ) { |
|
441 | + $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
442 | + } |
|
440 | 443 | |
441 | 444 | $action = empty($action) ? 'default' : $action; |
442 | 445 | |
@@ -510,8 +513,9 @@ discard block |
||
510 | 513 | * @return string html structure for status. |
511 | 514 | */ |
512 | 515 | public static function status_legend( $status_array, $active_status = '' ) { |
513 | - if ( !is_array( $status_array ) ) |
|
514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
516 | + if ( !is_array( $status_array ) ) { |
|
517 | + throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
518 | + } |
|
515 | 519 | |
516 | 520 | $setup_array = array(); |
517 | 521 | foreach ( $status_array as $item => $status ) { |
@@ -572,8 +576,7 @@ discard block |
||
572 | 576 | </tbody> |
573 | 577 | </table> |
574 | 578 | <?php |
575 | - } |
|
576 | - else { |
|
579 | + } else { |
|
577 | 580 | ?> |
578 | 581 | <ul> |
579 | 582 | <?php |
@@ -583,8 +586,7 @@ discard block |
||
583 | 586 | </ul> |
584 | 587 | <?php |
585 | 588 | } |
586 | - } |
|
587 | - else { |
|
589 | + } else { |
|
588 | 590 | //simple value |
589 | 591 | echo $data; |
590 | 592 | } |
@@ -664,8 +666,9 @@ discard block |
||
664 | 666 | |
665 | 667 | $total_pages = ceil( $total_items / $per_page ); |
666 | 668 | |
667 | - if ( $total_pages <= 1 ) |
|
668 | - return ''; |
|
669 | + if ( $total_pages <= 1 ) { |
|
670 | + return ''; |
|
671 | + } |
|
669 | 672 | |
670 | 673 | $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
671 | 674 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
102 | - unset( $espresso_themes[ $key ] ); |
|
102 | + unset( $espresso_themes[ $key ] ); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | ); |
710 | 710 | |
711 | 711 | if ( empty( $items_label ) |
712 | - || ! is_array( $items_label ) |
|
713 | - || ! isset( $items_label['single'] ) |
|
714 | - || ! isset( $items_label['plural'] ) ) { |
|
712 | + || ! is_array( $items_label ) |
|
713 | + || ! isset( $items_label['single'] ) |
|
714 | + || ! isset( $items_label['plural'] ) ) { |
|
715 | 715 | $items_label = array( |
716 | 716 | 'single' => __( '1 item', 'event_espresso' ), |
717 | 717 | 'plural' => __( '%s items', 'event_espresso' ) |
@@ -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,50 +407,50 @@ 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 | 418 | $amount = (float) $amount; |
419 | 419 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
420 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
420 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
421 | 421 | // still a number or was amount converted to a string like "free" ? |
422 | - if ( is_float( $amount_formatted )) { |
|
422 | + if (is_float($amount_formatted)) { |
|
423 | 423 | // was a country ISO code passed ? if so generate currency config object for that country |
424 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
424 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
425 | 425 | // verify results |
426 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
426 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
427 | 427 | // set default config country currency settings |
428 | 428 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
429 | 429 | } |
430 | 430 | // format float |
431 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
431 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
432 | 432 | // add formatting ? |
433 | - if ( ! $return_raw ) { |
|
433 | + if ( ! $return_raw) { |
|
434 | 434 | // add currency sign |
435 | - if( $mny->sign_b4 ){ |
|
436 | - if( $amount >= 0 ){ |
|
437 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
438 | - }else{ |
|
439 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
435 | + if ($mny->sign_b4) { |
|
436 | + if ($amount >= 0) { |
|
437 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
438 | + } else { |
|
439 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
440 | 440 | } |
441 | 441 | |
442 | - }else{ |
|
443 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
442 | + } else { |
|
443 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | // add currency code ? |
447 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
447 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
448 | 448 | } |
449 | 449 | // filter results |
450 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
450 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
451 | 451 | } |
452 | 452 | // clean up vars |
453 | - unset( $mny ); |
|
453 | + unset($mny); |
|
454 | 454 | // return formatted currency amount |
455 | 455 | return $amount_formatted; |
456 | 456 | } |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
466 | 466 | * @return string The localized label for the status id. |
467 | 467 | */ |
468 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
468 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
469 | 469 | /** @type EEM_Status $EEM_Status */ |
470 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
471 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
472 | - return $status[ $status_id ]; |
|
470 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
471 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
472 | + return $status[$status_id]; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -482,9 +482,9 @@ discard block |
||
482 | 482 | * @param string $icon |
483 | 483 | * @return string the html output for the button |
484 | 484 | */ |
485 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
486 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
487 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
485 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
486 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
487 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
488 | 488 | return $button; |
489 | 489 | } |
490 | 490 | |
@@ -501,21 +501,21 @@ discard block |
||
501 | 501 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
502 | 502 | * @return string generated link |
503 | 503 | */ |
504 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
504 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
505 | 505 | |
506 | - if ( ! $page ) |
|
507 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
506 | + if ( ! $page) |
|
507 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
508 | 508 | |
509 | - if ( ! $action ) |
|
510 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
509 | + if ( ! $action) |
|
510 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
511 | 511 | |
512 | 512 | $action = empty($action) ? 'default' : $action; |
513 | 513 | |
514 | 514 | |
515 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
516 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
517 | - $help_text = !$help_text ? '' : $help_text; |
|
518 | - 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>'; |
|
515 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
516 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
517 | + $help_text = ! $help_text ? '' : $help_text; |
|
518 | + 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>'; |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -527,31 +527,31 @@ discard block |
||
527 | 527 | * @param EE_Help_Tour |
528 | 528 | * @return string html |
529 | 529 | */ |
530 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
530 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
531 | 531 | $id = $tour->get_slug(); |
532 | 532 | $stops = $tour->get_stops(); |
533 | 533 | |
534 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
534 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
535 | 535 | |
536 | - foreach ( $stops as $stop ) { |
|
537 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
538 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
536 | + foreach ($stops as $stop) { |
|
537 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
538 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
539 | 539 | |
540 | 540 | //if container is set to modal then let's make sure we set the options accordingly |
541 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
541 | + if (empty($data_id) && empty($data_class)) { |
|
542 | 542 | $stop['options']['modal'] = true; |
543 | 543 | $stop['options']['expose'] = true; |
544 | 544 | } |
545 | 545 | |
546 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
547 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
546 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
547 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
548 | 548 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
549 | 549 | |
550 | 550 | //options |
551 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
551 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
552 | 552 | $options = ' data-options="'; |
553 | - foreach ( $stop['options'] as $option => $value ) { |
|
554 | - $options .= $option . ':' . $value . ';'; |
|
553 | + foreach ($stop['options'] as $option => $value) { |
|
554 | + $options .= $option.':'.$value.';'; |
|
555 | 555 | } |
556 | 556 | $options .= '"'; |
557 | 557 | } else { |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | } |
560 | 560 | |
561 | 561 | //let's put all together |
562 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
562 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | $content .= '</ol>'; |
@@ -580,31 +580,31 @@ discard block |
||
580 | 580 | * @throws EE_Error |
581 | 581 | * @return string html structure for status. |
582 | 582 | */ |
583 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
584 | - if ( !is_array( $status_array ) ) |
|
585 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
583 | + public static function status_legend($status_array, $active_status = '') { |
|
584 | + if ( ! is_array($status_array)) |
|
585 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
586 | 586 | |
587 | 587 | $setup_array = array(); |
588 | - foreach ( $status_array as $item => $status ) { |
|
588 | + foreach ($status_array as $item => $status) { |
|
589 | 589 | $setup_array[$item] = array( |
590 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
591 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
590 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
591 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
592 | 592 | 'status' => $status |
593 | 593 | ); |
594 | 594 | } |
595 | 595 | |
596 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
597 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
598 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
599 | - foreach ( $setup_array as $item => $details ) { |
|
596 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
597 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
598 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
599 | + foreach ($setup_array as $item => $details) { |
|
600 | 600 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
601 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
602 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
603 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
604 | - $content .= '</dt>' . "\n"; |
|
601 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
602 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
603 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
604 | + $content .= '</dt>'."\n"; |
|
605 | 605 | } |
606 | - $content .= '</dl>' . "\n"; |
|
607 | - $content .= '</div>' . "\n"; |
|
606 | + $content .= '</dl>'."\n"; |
|
607 | + $content .= '</div>'."\n"; |
|
608 | 608 | return $content; |
609 | 609 | } |
610 | 610 | |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | * @return string |
618 | 618 | */ |
619 | 619 | public static function layout_array_as_table($data) { |
620 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
621 | - $data = (array)$data; |
|
620 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
621 | + $data = (array) $data; |
|
622 | 622 | } |
623 | 623 | ob_start(); |
624 | 624 | if (is_array($data)) { |
@@ -631,10 +631,10 @@ discard block |
||
631 | 631 | ?> |
632 | 632 | <tr> |
633 | 633 | <td> |
634 | - <?php echo $data_key;?> |
|
634 | + <?php echo $data_key; ?> |
|
635 | 635 | </td> |
636 | 636 | <td> |
637 | - <?php echo self::layout_array_as_table($data_values);?> |
|
637 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
638 | 638 | </td> |
639 | 639 | </tr> |
640 | 640 | <?php |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | <ul> |
649 | 649 | <?php |
650 | 650 | foreach ($data as $datum) { |
651 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
651 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
652 | 652 | }?> |
653 | 653 | </ul> |
654 | 654 | <?php |
@@ -678,8 +678,8 @@ discard block |
||
678 | 678 | * |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
682 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
681 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
682 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | |
@@ -703,13 +703,13 @@ discard block |
||
703 | 703 | * ) |
704 | 704 | * @return string |
705 | 705 | */ |
706 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
706 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
707 | 707 | $page_links = array(); |
708 | 708 | $disable_first = $disable_last = ''; |
709 | 709 | $total_items = (int) $total_items; |
710 | 710 | $per_page = (int) $per_page; |
711 | 711 | $current = (int) $current; |
712 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
712 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
713 | 713 | |
714 | 714 | //filter items_label |
715 | 715 | $items_label = apply_filters( |
@@ -717,68 +717,68 @@ discard block |
||
717 | 717 | $items_label |
718 | 718 | ); |
719 | 719 | |
720 | - if ( empty( $items_label ) |
|
721 | - || ! is_array( $items_label ) |
|
722 | - || ! isset( $items_label['single'] ) |
|
723 | - || ! isset( $items_label['plural'] ) ) { |
|
720 | + if (empty($items_label) |
|
721 | + || ! is_array($items_label) |
|
722 | + || ! isset($items_label['single']) |
|
723 | + || ! isset($items_label['plural'])) { |
|
724 | 724 | $items_label = array( |
725 | - 'single' => __( '1 item', 'event_espresso' ), |
|
726 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
725 | + 'single' => __('1 item', 'event_espresso'), |
|
726 | + 'plural' => __('%s items', 'event_espresso') |
|
727 | 727 | ); |
728 | 728 | } else { |
729 | 729 | $items_label = array( |
730 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
731 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
730 | + 'single' => '1 '.esc_html($items_label['single']), |
|
731 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
732 | 732 | ); |
733 | 733 | } |
734 | 734 | |
735 | - $total_pages = ceil( $total_items / $per_page ); |
|
735 | + $total_pages = ceil($total_items / $per_page); |
|
736 | 736 | |
737 | - if ( $total_pages <= 1 ) |
|
737 | + if ($total_pages <= 1) |
|
738 | 738 | return ''; |
739 | 739 | |
740 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
740 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
741 | 741 | |
742 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
742 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
743 | 743 | |
744 | - if ( $current === 1 ) { |
|
744 | + if ($current === 1) { |
|
745 | 745 | $disable_first = ' disabled'; |
746 | 746 | } |
747 | - if ( $current == $total_pages ) { |
|
747 | + if ($current == $total_pages) { |
|
748 | 748 | $disable_last = ' disabled'; |
749 | 749 | } |
750 | 750 | |
751 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
752 | - 'first-page' . $disable_first, |
|
753 | - esc_attr__( 'Go to the first page' ), |
|
754 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
751 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
752 | + 'first-page'.$disable_first, |
|
753 | + esc_attr__('Go to the first page'), |
|
754 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
755 | 755 | '«' |
756 | 756 | ); |
757 | 757 | |
758 | 758 | $page_links[] = sprintf( |
759 | 759 | '<a class="%s" title="%s" href="%s">%s</a>', |
760 | - 'prev-page' . $disable_first, |
|
761 | - esc_attr__( 'Go to the previous page' ), |
|
762 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
760 | + 'prev-page'.$disable_first, |
|
761 | + esc_attr__('Go to the previous page'), |
|
762 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
763 | 763 | '‹' |
764 | 764 | ); |
765 | 765 | |
766 | - if ( ! $show_num_field ) { |
|
766 | + if ( ! $show_num_field) { |
|
767 | 767 | $html_current_page = $current; |
768 | 768 | } else { |
769 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
770 | - esc_attr__( 'Current page' ), |
|
769 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
770 | + esc_attr__('Current page'), |
|
771 | 771 | $current, |
772 | - strlen( $total_pages ) |
|
772 | + strlen($total_pages) |
|
773 | 773 | ); |
774 | 774 | } |
775 | 775 | |
776 | 776 | $html_total_pages = sprintf( |
777 | 777 | '<span class="total-pages">%s</span>', |
778 | - number_format_i18n( $total_pages ) |
|
778 | + number_format_i18n($total_pages) |
|
779 | 779 | ); |
780 | 780 | $page_links[] = sprintf( |
781 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
781 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
782 | 782 | $html_current_page, |
783 | 783 | $html_total_pages, |
784 | 784 | '<span class="paging-input">', |
@@ -787,29 +787,29 @@ discard block |
||
787 | 787 | |
788 | 788 | $page_links[] = sprintf( |
789 | 789 | '<a class="%s" title="%s" href="%s">%s</a>', |
790 | - 'next-page' . $disable_last, |
|
791 | - esc_attr__( 'Go to the next page' ), |
|
792 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
790 | + 'next-page'.$disable_last, |
|
791 | + esc_attr__('Go to the next page'), |
|
792 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
793 | 793 | '›' |
794 | 794 | ); |
795 | 795 | |
796 | 796 | $page_links[] = sprintf( |
797 | 797 | '<a class="%s" title="%s" href="%s">%s</a>', |
798 | - 'last-page' . $disable_last, |
|
799 | - esc_attr__( 'Go to the last page' ), |
|
800 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
798 | + 'last-page'.$disable_last, |
|
799 | + esc_attr__('Go to the last page'), |
|
800 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
801 | 801 | '»' |
802 | 802 | ); |
803 | 803 | |
804 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
804 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
805 | 805 | // set page class |
806 | - if ( $total_pages ) { |
|
806 | + if ($total_pages) { |
|
807 | 807 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
808 | 808 | } else { |
809 | 809 | $page_class = ' no-pages'; |
810 | 810 | } |
811 | 811 | |
812 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
812 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
826 | 826 | |
827 | 827 | |
828 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
828 | +if ( ! function_exists('espresso_pagination')) { |
|
829 | 829 | /** |
830 | 830 | * espresso_pagination |
831 | 831 | * |
@@ -837,21 +837,21 @@ discard block |
||
837 | 837 | $big = 999999999; // need an unlikely integer |
838 | 838 | $pagination = paginate_links( |
839 | 839 | array( |
840 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
840 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
841 | 841 | 'format' => '?paged=%#%', |
842 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
842 | + 'current' => max(1, get_query_var('paged')), |
|
843 | 843 | 'total' => $wp_query->max_num_pages, |
844 | 844 | 'show_all' => true, |
845 | 845 | 'end_size' => 10, |
846 | 846 | 'mid_size' => 6, |
847 | 847 | 'prev_next' => true, |
848 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
849 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
848 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
849 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
850 | 850 | 'type' => 'plain', |
851 | 851 | 'add_args' => false, |
852 | 852 | 'add_fragment' => '' |
853 | 853 | ) |
854 | 854 | ); |
855 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
855 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
856 | 856 | } |
857 | 857 | } |
858 | 858 | \ No newline at end of file |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * |
295 | 295 | * given two paths, this determines if there is a common base path between the two |
296 | 296 | * |
297 | - * @param array $paths |
|
297 | + * @param string[] $paths |
|
298 | 298 | * @return string |
299 | 299 | */ |
300 | 300 | protected static function _find_common_base_path( $paths ) { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
322 | 322 | * @param array $template_args an array of arguments to be extracted for use in the template |
323 | 323 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
324 | - * @return mixed string |
|
324 | + * @return string string |
|
325 | 325 | */ |
326 | 326 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
327 | 327 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param mixed $info |
26 | 26 | * @return bool |
27 | 27 | */ |
28 | - public function add( $object, $info = null ); |
|
28 | + public function add($object, $info = null); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param mixed $info |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function set_info( $object, $info = null ); |
|
42 | + public function set_info($object, $info = null); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param mixed |
53 | 53 | * @return null | object |
54 | 54 | */ |
55 | - public function get_by_info( $info ); |
|
55 | + public function get_by_info($info); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param object $object |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function has( $object ); |
|
68 | + public function has($object); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param $object |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - public function remove( $object ); |
|
81 | + public function remove($object); |
|
82 | 82 | |
83 | 83 | |
84 | 84 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |