@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | * regardless of access. |
45 | 45 | * @return EE_Venue | null |
46 | 46 | */ |
47 | - public static function get_venue( $VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true ) { |
|
48 | - $VNU_ID = absint( $VNU_ID ); |
|
47 | + public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true) { |
|
48 | + $VNU_ID = absint($VNU_ID); |
|
49 | 49 | // do we already have the Venue you are looking for? |
50 | - if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID ) { |
|
51 | - return EEH_Venue_View::_get_venue( $privacy_check ); |
|
50 | + if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID) { |
|
51 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
52 | 52 | } |
53 | 53 | // international newspaper? |
54 | 54 | global $post; |
55 | - if ( $post instanceof WP_Post ) { |
|
56 | - switch ( $post->post_type ) { |
|
55 | + if ($post instanceof WP_Post) { |
|
56 | + switch ($post->post_type) { |
|
57 | 57 | // if this is being called from an EE_Venue post, |
58 | 58 | // and the EE_Venue post corresponds to the EE_Venue that is being asked for, |
59 | 59 | // then we can try to just grab the attached EE_Venue object |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | // the post already contains the related EE_Venue object AND one of the following is TRUE: |
62 | 62 | // the requested Venue ID matches the post ID OR... |
63 | 63 | // there was no specific Venue ID requested |
64 | - if ( isset( $post->EE_Venue ) && ( $VNU_ID == $post->ID || ! $VNU_ID )) { |
|
64 | + if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) { |
|
65 | 65 | // use existing related EE_Venue object |
66 | - EEH_Venue_View::$_venue = $post->EE_Venue; |
|
67 | - } else if ( $VNU_ID ) { |
|
66 | + EEH_Venue_View::$_venue = $post->EE_Venue; |
|
67 | + } else if ($VNU_ID) { |
|
68 | 68 | // there WAS a specific Venue ID requested, but it's NOT the current post object |
69 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
69 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
70 | 70 | } else { |
71 | 71 | // no specific Venue ID requested, so use post ID to generate EE_Venue object |
72 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $post->ID ); |
|
72 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); |
|
73 | 73 | } |
74 | 74 | break; |
75 | 75 | |
76 | 76 | case 'espresso_events': |
77 | - if ( $look_in_event ) { |
|
77 | + if ($look_in_event) { |
|
78 | 78 | // grab the events related venues |
79 | 79 | $venues = EEH_Venue_View::get_event_venues(); |
80 | 80 | // make sure the result is an array |
81 | - $venues = is_array( $venues ) ? $venues : array(); |
|
81 | + $venues = is_array($venues) ? $venues : array(); |
|
82 | 82 | // do we have an ID for a specific venue? |
83 | - if ( $VNU_ID ) { |
|
83 | + if ($VNU_ID) { |
|
84 | 84 | // loop thru the related venues |
85 | - foreach( $venues as $venue ) { |
|
86 | - if ( $venue instanceof EE_Venue ) { |
|
85 | + foreach ($venues as $venue) { |
|
86 | + if ($venue instanceof EE_Venue) { |
|
87 | 87 | // until we find the venue we're looking for |
88 | - if ( $venue->ID() == $VNU_ID ) { |
|
88 | + if ($venue->ID() == $VNU_ID) { |
|
89 | 89 | EEH_Venue_View::$_venue = $venue; |
90 | 90 | break; |
91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | // then the global post is an events post and this function was called with no argument |
98 | 98 | } else { |
99 | 99 | // just grab the first related event venue |
100 | - EEH_Venue_View::$_venue = reset( $venues ); |
|
100 | + EEH_Venue_View::$_venue = reset($venues); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | break; |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
108 | - if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) { |
|
108 | + if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
109 | 109 | // sigh... pull it from the db |
110 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
110 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
111 | 111 | } |
112 | - return EEH_Venue_View::_get_venue( $privacy_check ); |
|
112 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * regardless of access. |
122 | 122 | * @return EE_Venue |
123 | 123 | */ |
124 | - protected static function _get_venue( $privacy_check = true ) { |
|
124 | + protected static function _get_venue($privacy_check = true) { |
|
125 | 125 | // check for private venues. |
126 | - if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->status() == 'private' && $privacy_check && ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) { |
|
126 | + if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->status() == 'private' && $privacy_check && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
127 | 127 | return null; |
128 | 128 | } |
129 | 129 | return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null; |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public static function get_event_venues() { |
141 | 141 | global $post; |
142 | - if ( $post->post_type == 'espresso_events' ) { |
|
143 | - if ( isset( $post->EE_Event ) && $post->EE_Event instanceof EE_Event ) { |
|
142 | + if ($post->post_type == 'espresso_events') { |
|
143 | + if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) { |
|
144 | 144 | return $post->EE_Event->venues(); |
145 | 145 | } |
146 | 146 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return bool|null |
162 | 162 | */ |
163 | - public static function is_venue_private( $VNU_ID = false ) { |
|
164 | - $venue = EEH_Venue_View::get_venue( $VNU_ID, true, true ); |
|
165 | - if ( ! $venue instanceof EE_Venue ) { |
|
163 | + public static function is_venue_private($VNU_ID = false) { |
|
164 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true); |
|
165 | + if ( ! $venue instanceof EE_Venue) { |
|
166 | 166 | return null; |
167 | 167 | } |
168 | 168 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | * @param int $VNU_ID |
179 | 179 | * @return string |
180 | 180 | */ |
181 | - public static function venue_description( $VNU_ID = 0 ) { |
|
182 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
183 | - if ( $venue instanceof EE_Venue ) { |
|
181 | + public static function venue_description($VNU_ID = 0) { |
|
182 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
183 | + if ($venue instanceof EE_Venue) { |
|
184 | 184 | return$venue->description(); |
185 | 185 | } |
186 | 186 | return ''; |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | * @param int $VNU_ID |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - public static function venue_excerpt( $VNU_ID = 0 ) { |
|
199 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
200 | - if ( $venue instanceof EE_Venue ) { |
|
198 | + public static function venue_excerpt($VNU_ID = 0) { |
|
199 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
200 | + if ($venue instanceof EE_Venue) { |
|
201 | 201 | $excerpt = $venue->excerpt() != NULL && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
202 | - $venue_link = ' ' . EEH_Venue_View::venue_details_link( $venue->ID(), __( 'more', 'event_espresso' ) . '…' ); |
|
203 | - return ! empty( $excerpt ) ? wp_trim_words( $excerpt, 25, '' ) . $venue_link : ''; |
|
202 | + $venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'…'); |
|
203 | + return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : ''; |
|
204 | 204 | } |
205 | 205 | return ''; |
206 | 206 | } |
@@ -215,22 +215,22 @@ discard block |
||
215 | 215 | * @param bool $hide_uncategorized |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public static function venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE ) { |
|
218 | + public static function venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE) { |
|
219 | 219 | $category_links = array(); |
220 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
221 | - if ( $venue instanceof EE_Venue ) { |
|
220 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
221 | + if ($venue instanceof EE_Venue) { |
|
222 | 222 | // get category terms |
223 | - if ( $venue_categories = get_the_terms( $venue->ID(), 'espresso_venue_categories' )) { |
|
223 | + if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) { |
|
224 | 224 | // loop thru terms and create links |
225 | - foreach ( $venue_categories as $term ) { |
|
226 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
227 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
228 | - $category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a> '; |
|
225 | + foreach ($venue_categories as $term) { |
|
226 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
227 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
228 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> '; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
233 | - return implode( ', ', $category_links ); |
|
233 | + return implode(', ', $category_links); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param bool $add_wrapper |
246 | 246 | * @return string |
247 | 247 | */ |
248 | - public static function venue_address( $type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true ) { |
|
249 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
250 | - if ( $venue instanceof EE_Venue ) { |
|
251 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
252 | - return EEH_Address::format( $venue, $type, $use_schema, $add_wrapper ); |
|
248 | + public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) { |
|
249 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
250 | + if ($venue instanceof EE_Venue) { |
|
251 | + EE_Registry::instance()->load_helper('Formatter'); |
|
252 | + return EEH_Address::format($venue, $type, $use_schema, $add_wrapper); |
|
253 | 253 | } |
254 | 254 | return ''; |
255 | 255 | } |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * @param int $VNU_ID |
264 | 264 | * @return bool|string |
265 | 265 | */ |
266 | - public static function venue_has_address( $VNU_ID = 0 ) { |
|
267 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
268 | - if ( $venue instanceof EE_Venue ) { |
|
269 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
270 | - return EEH_Address::format( $venue, 'inline', FALSE, FALSE ); |
|
266 | + public static function venue_has_address($VNU_ID = 0) { |
|
267 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
268 | + if ($venue instanceof EE_Venue) { |
|
269 | + EE_Registry::instance()->load_helper('Formatter'); |
|
270 | + return EEH_Address::format($venue, 'inline', FALSE, FALSE); |
|
271 | 271 | } |
272 | 272 | return false; |
273 | 273 | } |
@@ -282,31 +282,31 @@ discard block |
||
282 | 282 | * @param int $VNU_ID |
283 | 283 | * @return string |
284 | 284 | */ |
285 | - public static function venue_name( $link_to = 'details', $VNU_ID = 0 ) { |
|
286 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
287 | - if ( $venue instanceof EE_Venue ) { |
|
288 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
285 | + public static function venue_name($link_to = 'details', $VNU_ID = 0) { |
|
286 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
287 | + if ($venue instanceof EE_Venue) { |
|
288 | + EE_Registry::instance()->load_helper('Formatter'); |
|
289 | 289 | $venue_name = apply_filters( |
290 | 290 | 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
291 | 291 | EEH_Venue_View::is_venue_private() |
292 | - ? EEH_Venue_View::$_venue->name() . " " . __( '(Private)', 'event_espresso' ) |
|
292 | + ? EEH_Venue_View::$_venue->name()." ".__('(Private)', 'event_espresso') |
|
293 | 293 | : EEH_Venue_View::$_venue->name(), |
294 | 294 | EEH_Venue_View::$_venue |
295 | 295 | ); |
296 | - $venue_name = EEH_Schema::name( $venue_name ); |
|
296 | + $venue_name = EEH_Schema::name($venue_name); |
|
297 | 297 | |
298 | 298 | //if venue is trashed then ignore the "link to" setting because the venue is trashed. |
299 | - if ( $venue->get('status') == 'trash' ) { |
|
299 | + if ($venue->get('status') == 'trash') { |
|
300 | 300 | $link_to = ''; |
301 | 301 | } |
302 | - switch( $link_to ) { |
|
302 | + switch ($link_to) { |
|
303 | 303 | |
304 | 304 | case 'details' : |
305 | - return EEH_Venue_View::venue_details_link( $venue->ID(), $venue_name ); |
|
305 | + return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name); |
|
306 | 306 | break; |
307 | 307 | |
308 | 308 | case 'website' : |
309 | - return EEH_Venue_View::venue_website_link( $venue->ID(), $venue_name ); |
|
309 | + return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name); |
|
310 | 310 | break; |
311 | 311 | |
312 | 312 | default : |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | * @param string $text |
327 | 327 | * @return string |
328 | 328 | */ |
329 | - public static function venue_details_link( $VNU_ID = 0, $text = '' ) { |
|
330 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
331 | - if ( $venue instanceof EE_Venue ) { |
|
332 | - return EEH_Schema::url( get_permalink( $venue->ID() ), $text ); |
|
329 | + public static function venue_details_link($VNU_ID = 0, $text = '') { |
|
330 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
331 | + if ($venue instanceof EE_Venue) { |
|
332 | + return EEH_Schema::url(get_permalink($venue->ID()), $text); |
|
333 | 333 | } |
334 | 334 | return ''; |
335 | 335 | } |
@@ -344,13 +344,13 @@ discard block |
||
344 | 344 | * @param string $text |
345 | 345 | * @return string |
346 | 346 | */ |
347 | - public static function venue_website_link( $VNU_ID = 0, $text = '' ) { |
|
348 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
349 | - if ( $venue instanceof EE_Venue ) { |
|
350 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
347 | + public static function venue_website_link($VNU_ID = 0, $text = '') { |
|
348 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
349 | + if ($venue instanceof EE_Venue) { |
|
350 | + EE_Registry::instance()->load_helper('Formatter'); |
|
351 | 351 | $url = $venue->venue_url(); |
352 | - $text = ! empty( $text ) ? $text : $url; |
|
353 | - return ! empty( $url ) ? EEH_Schema::url( $url, $text ) : ''; |
|
352 | + $text = ! empty($text) ? $text : $url; |
|
353 | + return ! empty($url) ? EEH_Schema::url($url, $text) : ''; |
|
354 | 354 | } |
355 | 355 | return ''; |
356 | 356 | } |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | * @param int $VNU_ID |
365 | 365 | * @return string |
366 | 366 | */ |
367 | - public static function venue_phone( $VNU_ID = 0) { |
|
368 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
369 | - if ( $venue instanceof EE_Venue ) { |
|
370 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
371 | - return EEH_Schema::telephone( $venue->phone() ); |
|
367 | + public static function venue_phone($VNU_ID = 0) { |
|
368 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
369 | + if ($venue instanceof EE_Venue) { |
|
370 | + EE_Registry::instance()->load_helper('Formatter'); |
|
371 | + return EEH_Schema::telephone($venue->phone()); |
|
372 | 372 | } |
373 | 373 | return ''; |
374 | 374 | } |
@@ -384,51 +384,51 @@ discard block |
||
384 | 384 | * @param array $gmap map options |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - public static function venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array() ) { |
|
387 | + public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array()) { |
|
388 | 388 | |
389 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
390 | - if ( $venue instanceof EE_Venue ) { |
|
389 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
390 | + if ($venue instanceof EE_Venue) { |
|
391 | 391 | // check for global espresso_events post and use it's ID if no map_ID is set |
392 | 392 | global $post; |
393 | - $map_ID = empty( $map_ID ) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
393 | + $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
394 | 394 | // grab map settings |
395 | 395 | $map_cfg = EE_Registry::instance()->CFG->map_settings; |
396 | 396 | // are maps enabled ? |
397 | - if ( $map_cfg->use_google_maps && $venue->enable_for_gmap() ) { |
|
397 | + if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
|
398 | 398 | |
399 | - EE_Registry::instance()->load_helper( 'Maps' ); |
|
400 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
399 | + EE_Registry::instance()->load_helper('Maps'); |
|
400 | + EE_Registry::instance()->load_helper('Formatter'); |
|
401 | 401 | |
402 | 402 | $details_page = is_single(); |
403 | 403 | $options = array(); |
404 | - $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
404 | + $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
405 | 405 | |
406 | - $options['location'] = EEH_Address::format( $venue, 'inline', FALSE, FALSE ); |
|
406 | + $options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE); |
|
407 | 407 | |
408 | 408 | $options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width; |
409 | - $options['ee_map_width'] = isset( $gmap['ee_map_width'] ) && ! empty( $gmap['ee_map_width'] ) ? $gmap['ee_map_width'] : $options['ee_map_width']; |
|
409 | + $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width']; |
|
410 | 410 | |
411 | 411 | $options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height; |
412 | - $options['ee_map_height'] = isset( $gmap['ee_map_height'] ) && ! empty( $gmap['ee_map_height'] ) ? $gmap['ee_map_height'] : $options['ee_map_height']; |
|
412 | + $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height']; |
|
413 | 413 | |
414 | 414 | $options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom; |
415 | - $options['ee_map_zoom'] = isset( $gmap['ee_map_zoom'] ) && ! empty( $gmap['ee_map_zoom'] ) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom']; |
|
415 | + $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom']; |
|
416 | 416 | |
417 | 417 | $options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav; |
418 | - $options['ee_map_nav_display'] = isset( $gmap['ee_map_nav_display'] ) && ! empty( $gmap['ee_map_nav_display'] ) ? 'true' : $options['ee_map_nav_display'];; |
|
418 | + $options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; ; |
|
419 | 419 | |
420 | 420 | $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size; |
421 | - $options['ee_map_nav_size'] = isset( $gmap['ee_map_nav_size'] ) && ! empty( $gmap['ee_map_nav_size'] )? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
421 | + $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
422 | 422 | |
423 | 423 | $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type; |
424 | - $options['ee_map_type_control'] = isset( $gmap['ee_map_type_control'] ) && ! empty( $gmap['ee_map_type_control'] )? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
424 | + $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
425 | 425 | |
426 | 426 | $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align; |
427 | - $options['ee_map_align'] = isset( $gmap['ee_map_align'] ) && ! empty( $gmap['ee_map_align'] )? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
427 | + $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
428 | 428 | |
429 | - $options['ee_static_url'] = isset( $gmap['ee_static_url'] ) && ! empty( $gmap['ee_static_url'] ) ? (bool)absint( $gmap['ee_static_url'] ) : $venue->google_map_link(); |
|
429 | + $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link(); |
|
430 | 430 | |
431 | - return EEH_Maps::google_map( $options ); |
|
431 | + return EEH_Maps::google_map($options); |
|
432 | 432 | |
433 | 433 | } |
434 | 434 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @param array $atts like EEH_Maps::google_map_link |
444 | 444 | * @return string |
445 | 445 | */ |
446 | - public static function espresso_google_static_map( EE_Venue $venue, $atts = array() ){ |
|
446 | + public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) { |
|
447 | 447 | EE_Registry::instance()->load_helper('Maps'); |
448 | 448 | $state = $venue->state_obj(); |
449 | 449 | $country = $venue->country_obj(); |
@@ -475,23 +475,23 @@ discard block |
||
475 | 475 | * @param string $after |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - public static function edit_venue_link( $VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>' ) { |
|
479 | - $venue = EEH_Venue_View::get_venue( $VNU_ID ); |
|
480 | - if ( $venue instanceof EE_Venue ) { |
|
478 | + public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') { |
|
479 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
480 | + if ($venue instanceof EE_Venue) { |
|
481 | 481 | // can the user edit this post ? |
482 | - if ( current_user_can( 'edit_post', $venue->ID() )) { |
|
482 | + if (current_user_can('edit_post', $venue->ID())) { |
|
483 | 483 | // set link text |
484 | - $link = ! empty( $link ) ? $link : __('edit this venue'); |
|
484 | + $link = ! empty($link) ? $link : __('edit this venue'); |
|
485 | 485 | // generate nonce |
486 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
486 | + $nonce = wp_create_nonce('edit_nonce'); |
|
487 | 487 | // generate url to venue editor for this venue |
488 | - $url = add_query_arg( array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url( 'admin.php' ) ); |
|
488 | + $url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php')); |
|
489 | 489 | // get edit CPT text |
490 | - $post_type_obj = get_post_type_object( 'espresso_venues' ); |
|
490 | + $post_type_obj = get_post_type_object('espresso_venues'); |
|
491 | 491 | // build final link html |
492 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>'; |
|
492 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
493 | 493 | // put it all together |
494 | - return $before . apply_filters( 'edit_post_link', $link, $venue->ID() ) . $after; |
|
494 | + return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after; |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | return ''; |
@@ -1,4 +1,6 @@ |
||
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 | * |
@@ -1,28 +1,28 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | /** |
16 | - * ------------------------------------------------------------------------ |
|
17 | - * |
|
18 | - * EEH_Venue_View Helper |
|
19 | - * |
|
20 | - * @package Event Espresso |
|
21 | - * @subpackage /core/ |
|
22 | - * @author Brent Christensen |
|
23 | - * |
|
24 | - * ------------------------------------------------------------------------ |
|
25 | - */ |
|
16 | + * ------------------------------------------------------------------------ |
|
17 | + * |
|
18 | + * EEH_Venue_View Helper |
|
19 | + * |
|
20 | + * @package Event Espresso |
|
21 | + * @subpackage /core/ |
|
22 | + * @author Brent Christensen |
|
23 | + * |
|
24 | + * ------------------------------------------------------------------------ |
|
25 | + */ |
|
26 | 26 | class EEH_Venue_View extends EEH_Base { |
27 | 27 | |
28 | 28 | /** |
@@ -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 @@ 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 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return bool | int |
31 | 31 | * @throws \EE_Error |
32 | 32 | */ |
33 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ); |
|
33 | + public function persist($persistence_callback = '', $persistence_arguments = array()); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $persistence_callback name of method found on object that can be used for persisting it |
44 | 44 | * @return bool | int |
45 | 45 | */ |
46 | - public function persist_all( $persistence_callback = '' ); |
|
46 | + public function persist_all($persistence_callback = ''); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | // End of file EEI_Repository.interface.php |
@@ -3,13 +3,13 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * Class EEI_Line_Item |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Mike Nelson / Brent Christensen |
|
11 | - * |
|
12 | - */ |
|
6 | + * Class EEI_Line_Item |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Mike Nelson / Brent Christensen |
|
11 | + * |
|
12 | + */ |
|
13 | 13 | interface EEI_Line_Item { |
14 | 14 | |
15 | 15 | /** |
@@ -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 | * Class EEI_Line_Item |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param mixed $field_value |
19 | 19 | * @param bool $use_default |
20 | 20 | */ |
21 | - public function set( $field_name, $field_value, $use_default = false ); |
|
21 | + public function set($field_name, $field_value, $use_default = false); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Sets quantity |
57 | 57 | * @param int $quantity |
58 | 58 | */ |
59 | - function set_quantity( $quantity ); |
|
59 | + function set_quantity($quantity); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
116 | 116 | * @return int count of items saved |
117 | 117 | */ |
118 | - function save_this_and_descendants_to_txn( $txn_id = null ); |
|
118 | + function save_this_and_descendants_to_txn($txn_id = null); |
|
119 | 119 | |
120 | 120 | |
121 | 121 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param bool $set_order |
143 | 143 | * @return bool true for success, false for fail |
144 | 144 | */ |
145 | - function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ); |
|
145 | + function add_child_line_item(EEI_Line_Item $line_item, $set_order = true); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param float $total |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - function set_total( $total ); |
|
200 | + function set_total($total); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Sets unit_price |
204 | 204 | * @param float $unit_price |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - function set_unit_price( $unit_price ); |
|
207 | + function set_unit_price($unit_price); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param bool $stop_search_once_found |
216 | 216 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
217 | 217 | */ |
218 | - function delete_child_line_item( $code, $stop_search_once_found = true ); |
|
218 | + function delete_child_line_item($code, $stop_search_once_found = true); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Forgets the cached model of the given relation Name. So the next time we request it, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param boolean $allow_persist |
239 | 239 | * @return boolean |
240 | 240 | */ |
241 | - function set_allow_persist( $allow_persist ); |
|
241 | + function set_allow_persist($allow_persist); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | } |
@@ -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 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param \EEI_Line_Item $line_item |
27 | 27 | * @return \EEI_Line_Item |
28 | 28 | */ |
29 | - public function process( EEI_Line_Item $line_item ); |
|
29 | + public function process(EEI_Line_Item $line_item); |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -class EE_Sample_Form extends EE_Form_Section_Proper{ |
|
3 | - function __construct(){ |
|
2 | +class EE_Sample_Form extends EE_Form_Section_Proper { |
|
3 | + function __construct() { |
|
4 | 4 | $this->_subsections = array( |
5 | 5 | 'h1'=>new EE_Form_Section_HTML('hello wordl'), |
6 | - 'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')), |
|
6 | + 'name'=>new EE_Text_Input(array('required'=>true, 'default'=>'your name here')), |
|
7 | 7 | 'email'=>new EE_Email_Input(array('required'=>false)), |
8 | - 'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=> __("Small", "event_espresso"),'m'=> __("Medium", "event_espresso"),'l'=> __("Large", "event_espresso")),array('required'=>true,'default'=>'s')), |
|
8 | + 'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=> __("Small", "event_espresso"), 'm'=> __("Medium", "event_espresso"), 'l'=> __("Large", "event_espresso")), array('required'=>true, 'default'=>'s')), |
|
9 | 9 | 'month_normal'=>new EE_Month_Input(), |
10 | 10 | 'month_leading_zero'=>new EE_Month_Input(true), |
11 | 11 | 'year_2'=>new EE_Year_Input(false, 1, 1), |
12 | - 'year_4'=>new EE_Year_Input(true, 0,10,array('default'=>'2017')), |
|
12 | + 'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')), |
|
13 | 13 | 'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=> __("Yes or No", "event_espresso"))), |
14 | 14 | 'credit_card'=>new EE_Credit_Card_Input(), |
15 | 15 | 'image_1'=>new EE_Admin_File_Uploader_Input(), |
16 | 16 | 'image_2'=>new EE_Admin_File_Uploader_Input(), |
17 | - 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'),array('default'=>array('php'))), |
|
17 | + 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP', 'mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
18 | 18 | 'float'=>new EE_Float_Input(), |
19 | 19 | 'essay'=>new EE_Text_Area_Input(), |
20 | 20 | 'amenities'=>new EE_Select_Multiple_Input( |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * Extra validation for the 'name' input. |
41 | 41 | * @param EE_Text_Input $form_input |
42 | 42 | */ |
43 | - function _validate_name($form_input){ |
|
44 | - if($form_input->raw_value() != 'Mike'){ |
|
43 | + function _validate_name($form_input) { |
|
44 | + if ($form_input->raw_value() != 'Mike') { |
|
45 | 45 | $form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike'); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - function _validate(){ |
|
49 | + function _validate() { |
|
50 | 50 | parent::_validate(); |
51 | - if($this->_subsections['shirt_size']->normalized_value() =='s' |
|
52 | - && $this->_subsections['year_4']->normalized_value() < 2010){ |
|
51 | + if ($this->_subsections['shirt_size']->normalized_value() == 's' |
|
52 | + && $this->_subsections['year_4']->normalized_value() < 2010) { |
|
53 | 53 | $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old'); |
54 | 54 | } |
55 | 55 | } |
@@ -2,16 +2,16 @@ |
||
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) |
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | - * EE_Form_Section_HTML |
|
6 | - * HTML to be laid out like a proper subsection |
|
7 | - * |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage |
|
11 | - * @author Mike Nelson |
|
12 | - * |
|
13 | - * ------------------------------------------------------------------------ |
|
14 | - */ |
|
5 | + * EE_Form_Section_HTML |
|
6 | + * HTML to be laid out like a proper subsection |
|
7 | + * |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage |
|
11 | + * @author Mike Nelson |
|
12 | + * |
|
13 | + * ------------------------------------------------------------------------ |
|
14 | + */ |
|
15 | 15 | class EE_Form_Section_HTML extends EE_Form_Section_Base{ |
16 | 16 | |
17 | 17 | protected $_html = ''; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | 5 | * EE_Form_Section_HTML |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * ------------------------------------------------------------------------ |
14 | 14 | */ |
15 | -class EE_Form_Section_HTML extends EE_Form_Section_Base{ |
|
15 | +class EE_Form_Section_HTML extends EE_Form_Section_Base { |
|
16 | 16 | |
17 | 17 | protected $_html = ''; |
18 | 18 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param string $html |
23 | 23 | * @param array $options_array |
24 | 24 | */ |
25 | - public function __construct( $html = '', $options_array = array() ) { |
|
25 | + public function __construct($html = '', $options_array = array()) { |
|
26 | 26 | $this->_html = $html; |
27 | - parent::__construct( $options_array ); |
|
27 | + parent::__construct($options_array); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML{ |
|
29 | - public function __construct($template_file,$args = array(), $options_array = array()) { |
|
28 | +class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML { |
|
29 | + public function __construct($template_file, $args = array(), $options_array = array()) { |
|
30 | 30 | EE_Registry::instance()->load_helper('Template'); |
31 | - $html = EEH_Template::locate_template( $template_file, $args ); |
|
31 | + $html = EEH_Template::locate_template($template_file, $args); |
|
32 | 32 | |
33 | 33 | // echo " filepath:$template_file html $html"; |
34 | 34 | parent::__construct($html, $options_array); |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if(isset($default_data[$subsection_name])){ |
210 | 210 | if($subsection instanceof EE_Form_Input_Base){ |
211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
212 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
214 | 214 | } |
215 | 215 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | foreach($this->subsections() as $subsection){ |
441 | 441 | if( $subsection instanceof EE_Form_Input_Base ){ |
442 | 442 | $inputs[ $subsection->html_name() ] = $subsection; |
443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
443 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
445 | 445 | } |
446 | 446 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | foreach($this->get_validatable_subsections() as $subsection){ |
549 | 549 | try{ |
550 | 550 | $subsection->_normalize($req_data); |
551 | - }catch( EE_Validation_Error $e ){ |
|
551 | + } catch( EE_Validation_Error $e ){ |
|
552 | 552 | $subsection->add_validation_error( $e ); |
553 | 553 | } |
554 | 554 | } |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | public function html_name_prefix(){ |
867 | 867 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
868 | 868 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
869 | - }else{ |
|
869 | + } else{ |
|
870 | 870 | return $this->name(); |
871 | 871 | } |
872 | 872 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | if( $subsection->form_data_present_in( $req_data ) ) { |
919 | 919 | return TRUE; |
920 | 920 | } |
921 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
921 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
922 | 922 | if( $subsection->form_data_present_in( $req_data ) ) { |
923 | 923 | return TRUE; |
924 | 924 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
69 | 69 | * |
70 | 70 | */ |
71 | - public function __construct( $options_array = array() ){ |
|
71 | + public function __construct($options_array = array()) { |
|
72 | 72 | EE_Registry::instance()->load_helper('Formatter'); |
73 | - $options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
73 | + $options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
74 | 74 | //call parent first, as it may be setting the name |
75 | 75 | parent::__construct($options_array); |
76 | 76 | //if they've included subsections in the constructor, add them now |
77 | - if( isset( $options_array['include'] )){ |
|
77 | + if (isset($options_array['include'])) { |
|
78 | 78 | //we are going to make sure we ONLY have those subsections to include |
79 | 79 | //AND we are going to make sure they're in that specified order |
80 | 80 | $reordered_subsections = array(); |
81 | - foreach($options_array['include'] as $input_name){ |
|
82 | - if(isset($this->_subsections[$input_name])){ |
|
81 | + foreach ($options_array['include'] as $input_name) { |
|
82 | + if (isset($this->_subsections[$input_name])) { |
|
83 | 83 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | $this->_subsections = $reordered_subsections; |
87 | 87 | } |
88 | - if(isset($options_array['exclude'])){ |
|
88 | + if (isset($options_array['exclude'])) { |
|
89 | 89 | $exclude = $options_array['exclude']; |
90 | 90 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
91 | 91 | } |
92 | - if(isset($options_array['layout_strategy'])){ |
|
92 | + if (isset($options_array['layout_strategy'])) { |
|
93 | 93 | $this->_layout_strategy = $options_array['layout_strategy']; |
94 | 94 | } |
95 | - if( ! $this->_layout_strategy){ |
|
95 | + if ( ! $this->_layout_strategy) { |
|
96 | 96 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
97 | 97 | } |
98 | 98 | $this->_layout_strategy->_construct_finalize($this); |
99 | 99 | |
100 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
101 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
102 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
100 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
101 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
102 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | * @param string $name |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
114 | + public function _construct_finalize($parent_form_section, $name) { |
|
115 | 115 | parent::_construct_finalize($parent_form_section, $name); |
116 | 116 | $this->_set_default_name_if_empty(); |
117 | 117 | $this->_set_default_html_id_if_empty(); |
118 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
119 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
120 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
118 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
119 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
120 | + $subsection->_construct_finalize($this, $subsection_name); |
|
121 | 121 | } else { |
122 | 122 | throw new EE_Error( |
123 | 123 | sprintf( |
124 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
124 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
125 | 125 | $subsection_name, |
126 | 126 | get_class($this), |
127 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
127 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | } |
131 | 131 | } |
132 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
132 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * Gets the layout strategy for this form section |
139 | 139 | * @return EE_Form_Section_Layout_Base |
140 | 140 | */ |
141 | - public function get_layout_strategy(){ |
|
141 | + public function get_layout_strategy() { |
|
142 | 142 | return $this->_layout_strategy; |
143 | 143 | } |
144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param EE_Form_Input_Base $input |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_html_for_input($input){ |
|
153 | + public function get_html_for_input($input) { |
|
154 | 154 | return $this->_layout_strategy->layout_input($input); |
155 | 155 | } |
156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param null $form_data |
164 | 164 | * @return boolean |
165 | 165 | */ |
166 | - public function was_submitted($form_data = NULL){ |
|
166 | + public function was_submitted($form_data = NULL) { |
|
167 | 167 | return $this->form_data_present_in($form_data); |
168 | 168 | } |
169 | 169 | |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | * to skip this step. |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
188 | - if( $req_data === NULL){ |
|
187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
188 | + if ($req_data === NULL) { |
|
189 | 189 | $req_data = $_REQUEST; |
190 | 190 | } |
191 | 191 | $this->_normalize($req_data); |
192 | - if( $validate ){ |
|
192 | + if ($validate) { |
|
193 | 193 | $this->_validate(); |
194 | 194 | } |
195 | 195 | } |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | * the value being an array formatted in teh same way |
205 | 205 | * @param array $default_data |
206 | 206 | */ |
207 | - public function populate_defaults($default_data){ |
|
208 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
209 | - if(isset($default_data[$subsection_name])){ |
|
210 | - if($subsection instanceof EE_Form_Input_Base){ |
|
207 | + public function populate_defaults($default_data) { |
|
208 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
209 | + if (isset($default_data[$subsection_name])) { |
|
210 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
212 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
214 | 214 | } |
215 | 215 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
228 | 228 | * @return EE_Form_Section_Base |
229 | 229 | */ |
230 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
231 | - if( $require_construction_to_be_finalized ){ |
|
230 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
231 | + if ($require_construction_to_be_finalized) { |
|
232 | 232 | $this->ensure_construct_finalized_called(); |
233 | 233 | } |
234 | 234 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | * Gets all the validatable subsections of this form section |
241 | 241 | * @return EE_Form_Section_Validatable[] |
242 | 242 | */ |
243 | - public function get_validatable_subsections(){ |
|
243 | + public function get_validatable_subsections() { |
|
244 | 244 | $validatable_subsections = array(); |
245 | - foreach($this->subsections() as $name=>$obj){ |
|
246 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
245 | + foreach ($this->subsections() as $name=>$obj) { |
|
246 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
247 | 247 | $validatable_subsections[$name] = $obj; |
248 | 248 | } |
249 | 249 | } |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * @return EE_Form_Input_Base |
264 | 264 | * @throws EE_Error |
265 | 265 | */ |
266 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
266 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
267 | 267 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
268 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
269 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
268 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
269 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
270 | 270 | } |
271 | 271 | return $subsection; |
272 | 272 | } |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | * @return EE_Form_Section_Proper |
285 | 285 | * @throws EE_Error |
286 | 286 | */ |
287 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
288 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
289 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
290 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
287 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
288 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
289 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
290 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
291 | 291 | } |
292 | 292 | return $subsection; |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param string $name |
301 | 301 | * @return mixed depending on the input's type and its normalization strategy |
302 | 302 | */ |
303 | - public function get_input_value($name){ |
|
303 | + public function get_input_value($name) { |
|
304 | 304 | $input = $this->get_input($name); |
305 | 305 | return $input->normalized_value(); |
306 | 306 | } |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | * @return boolean |
314 | 314 | */ |
315 | 315 | public function is_valid() { |
316 | - if( ! $this->has_received_submission()){ |
|
316 | + if ( ! $this->has_received_submission()) { |
|
317 | 317 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
318 | 318 | } |
319 | - if( ! parent::is_valid()){ |
|
319 | + if ( ! parent::is_valid()) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | //ok so no errors general to this entire form section. so let's check the subsections |
323 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
324 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
325 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
323 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
324 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
325 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | } |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | * gets teh default name of this form section if none is specified |
336 | 336 | * @return string |
337 | 337 | */ |
338 | - protected function _set_default_name_if_empty(){ |
|
339 | - if( ! $this->_name ){ |
|
338 | + protected function _set_default_name_if_empty() { |
|
339 | + if ( ! $this->_name) { |
|
340 | 340 | $classname = get_class($this); |
341 | 341 | $default_name = str_replace("EE_", "", $classname); |
342 | - $this->_name = $default_name; |
|
342 | + $this->_name = $default_name; |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * Also returns the HTML for the form, except for the form opening and closing tags |
351 | 351 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
352 | 352 | */ |
353 | - public function get_html_and_js(){ |
|
353 | + public function get_html_and_js() { |
|
354 | 354 | $this->enqueue_js(); |
355 | 355 | return $this->get_html(); |
356 | 356 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public function get_html(){ |
|
364 | + public function get_html() { |
|
365 | 365 | $this->ensure_construct_finalized_called(); |
366 | 366 | return $this->_layout_strategy->layout_form(); |
367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * enqueues JS for the form |
373 | 373 | * @return string |
374 | 374 | */ |
375 | - public function enqueue_js(){ |
|
375 | + public function enqueue_js() { |
|
376 | 376 | $this->_enqueue_and_localize_form_js(); |
377 | 377 | } |
378 | 378 | |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | * could change until it's actually outputted) |
388 | 388 | * @return void |
389 | 389 | */ |
390 | - public static function wp_enqueue_scripts(){ |
|
391 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
392 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
390 | + public static function wp_enqueue_scripts() { |
|
391 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
392 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
400 | 400 | * but before the wordpress hook wp_loaded |
401 | 401 | */ |
402 | - public function _enqueue_and_localize_form_js(){ |
|
402 | + public function _enqueue_and_localize_form_js() { |
|
403 | 403 | $this->ensure_construct_finalized_called(); |
404 | 404 | //actually, we don't want to localize just yet. There may be other forms on the page. |
405 | 405 | //so we need to add our form section data to a static variable accessible by all form sections |
406 | 406 | //and localize it just before the footer |
407 | 407 | $this->localize_validation_rules(); |
408 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
409 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
408 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
409 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | * @param bool $return_for_subsection |
417 | 417 | * @return void |
418 | 418 | */ |
419 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
419 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
420 | 420 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
421 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
422 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
423 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
421 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
422 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
423 | + 'form_section_id'=> $this->html_id(TRUE), |
|
424 | 424 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
425 | 425 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
426 | 426 | ); |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | * Keys are their form names, and values are the inputs themselves |
436 | 436 | * @return EE_Form_Input_Base |
437 | 437 | */ |
438 | - public function inputs_in_subsections(){ |
|
438 | + public function inputs_in_subsections() { |
|
439 | 439 | $inputs = array(); |
440 | - foreach($this->subsections() as $subsection){ |
|
441 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
442 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
440 | + foreach ($this->subsections() as $subsection) { |
|
441 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
442 | + $inputs[$subsection->html_name()] = $subsection; |
|
443 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
445 | 445 | } |
446 | 446 | } |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | * and values are a string of all their validation errors |
454 | 454 | * @return string[] |
455 | 455 | */ |
456 | - public function subsection_validation_errors_by_html_name(){ |
|
456 | + public function subsection_validation_errors_by_html_name() { |
|
457 | 457 | $inputs = $this->inputs(); |
458 | 458 | $errors = array(); |
459 | - foreach( $inputs as $form_input ){ |
|
460 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
461 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
459 | + foreach ($inputs as $form_input) { |
|
460 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
461 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | return $errors; |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
471 | 471 | * Should be setup by each form during the _enqueues_and_localize_form_js |
472 | 472 | */ |
473 | - public static function localize_script_for_all_forms(){ |
|
473 | + public static function localize_script_for_all_forms() { |
|
474 | 474 | //allow inputs and stuff to hook in their JS and stuff here |
475 | 475 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
476 | 476 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
477 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
478 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
477 | + wp_enqueue_script('ee_form_section_validation'); |
|
478 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | /** |
484 | 484 | * ensure_scripts_localized |
485 | 485 | */ |
486 | - public function ensure_scripts_localized(){ |
|
487 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
486 | + public function ensure_scripts_localized() { |
|
487 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
488 | 488 | $this->_enqueue_and_localize_form_js(); |
489 | 489 | } |
490 | 490 | } |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | * is that the key here should be the same as the custom validation rule put in the JS file |
497 | 497 | * @return array keys are custom validation rules, and values are internationalized strings |
498 | 498 | */ |
499 | - private static function _get_localized_error_messages(){ |
|
499 | + private static function _get_localized_error_messages() { |
|
500 | 500 | return array( |
501 | 501 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
502 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
502 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
503 | 503 | ); |
504 | 504 | } |
505 | 505 | |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
528 | 528 | * @return array |
529 | 529 | */ |
530 | - function get_jquery_validation_rules(){ |
|
530 | + function get_jquery_validation_rules() { |
|
531 | 531 | $jquery_validation_rules = array(); |
532 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
533 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
532 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
533 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
534 | 534 | } |
535 | 535 | return $jquery_validation_rules; |
536 | 536 | } |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | protected function _normalize($req_data) { |
546 | 546 | $this->_received_submission = TRUE; |
547 | 547 | $this->_validation_errors = array(); |
548 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
549 | - try{ |
|
548 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
549 | + try { |
|
550 | 550 | $subsection->_normalize($req_data); |
551 | - }catch( EE_Validation_Error $e ){ |
|
552 | - $subsection->add_validation_error( $e ); |
|
551 | + } catch (EE_Validation_Error $e) { |
|
552 | + $subsection->add_validation_error($e); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * calling parent::_validate() first. |
564 | 564 | */ |
565 | 565 | protected function _validate() { |
566 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
567 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
568 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
566 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
567 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
568 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
569 | 569 | } |
570 | 570 | $subsection->_validate(); |
571 | 571 | } |
@@ -577,13 +577,13 @@ discard block |
||
577 | 577 | * Gets all the validated inputs for the form section |
578 | 578 | * @return array |
579 | 579 | */ |
580 | - public function valid_data(){ |
|
580 | + public function valid_data() { |
|
581 | 581 | $inputs = array(); |
582 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
583 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
584 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
585 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
586 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
582 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
583 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
584 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
585 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
586 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
587 | 587 | } |
588 | 588 | } |
589 | 589 | return $inputs; |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | * Gets all the inputs on this form section |
596 | 596 | * @return EE_Form_Input_Base[] |
597 | 597 | */ |
598 | - public function inputs(){ |
|
598 | + public function inputs() { |
|
599 | 599 | $inputs = array(); |
600 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
601 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
602 | - $inputs[ $subsection_name ] = $subsection; |
|
600 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
601 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
602 | + $inputs[$subsection_name] = $subsection; |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | return $inputs; |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | * Gets all the subsections which are a proper form |
612 | 612 | * @return EE_Form_Section_Proper[] |
613 | 613 | */ |
614 | - public function subforms(){ |
|
614 | + public function subforms() { |
|
615 | 615 | $form_sections = array(); |
616 | - foreach($this->subsections() as $name=>$obj){ |
|
617 | - if($obj instanceof EE_Form_Section_Proper){ |
|
616 | + foreach ($this->subsections() as $name=>$obj) { |
|
617 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
618 | 618 | $form_sections[$name] = $obj; |
619 | 619 | } |
620 | 620 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * if you only want form inputs or proper form sections. |
630 | 630 | * @return EE_Form_Section_Proper[] |
631 | 631 | */ |
632 | - public function subsections(){ |
|
632 | + public function subsections() { |
|
633 | 633 | $this->ensure_construct_finalized_called(); |
634 | 634 | return $this->_subsections; |
635 | 635 | } |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * it can be a multidimensional array where keys are always subsection names and values are either the |
648 | 648 | * input's normalized value, or an array like the top-level array |
649 | 649 | */ |
650 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
651 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
650 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
651 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -664,8 +664,8 @@ discard block |
||
664 | 664 | * it can be a multidimensional array where keys are always subsection names and values are either the |
665 | 665 | * input's normalized value, or an array like the top-level array |
666 | 666 | */ |
667 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
668 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
667 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
668 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -678,17 +678,17 @@ discard block |
||
678 | 678 | * it can be a multidimensional array where keys are always subsection names and values are either the |
679 | 679 | * input's normalized value, or an array like the top-level array |
680 | 680 | */ |
681 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
681 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
682 | 682 | $input_values = array(); |
683 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
684 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
685 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
686 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
687 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
688 | - if( $flatten ) { |
|
689 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
683 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
684 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
685 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
686 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
687 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
688 | + if ($flatten) { |
|
689 | + $input_values = array_merge($input_values, $subform_input_values); |
|
690 | 690 | } else { |
691 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
691 | + $input_values[$subsection_name] = $subform_input_values; |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * (ie, had receive_form_submission called on it yet) |
703 | 703 | * @return boolean |
704 | 704 | */ |
705 | - public function has_received_submission(){ |
|
705 | + public function has_received_submission() { |
|
706 | 706 | $this->ensure_construct_finalized_called(); |
707 | 707 | return $this->_received_submission; |
708 | 708 | } |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | * @param array $inputs_to_exclude values are the input names |
716 | 716 | * @return void |
717 | 717 | */ |
718 | - public function exclude($inputs_to_exclude = array()){ |
|
719 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
718 | + public function exclude($inputs_to_exclude = array()) { |
|
719 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
720 | 720 | unset($this->_subsections[$input_to_exclude_name]); |
721 | 721 | } |
722 | 722 | } |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | /** |
727 | 727 | * @param array $inputs_to_hide |
728 | 728 | */ |
729 | - public function hide($inputs_to_hide= array()){ |
|
730 | - foreach($inputs_to_hide as $input_to_hide){ |
|
729 | + public function hide($inputs_to_hide = array()) { |
|
730 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
731 | 731 | $input = $this->get_input($input_to_hide); |
732 | 732 | |
733 | 733 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -752,13 +752,13 @@ discard block |
||
752 | 752 | * or if $subsection_name_to_target is null, before or after entire subsections array |
753 | 753 | * @return void |
754 | 754 | */ |
755 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
756 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
757 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
755 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
756 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
757 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
758 | 758 | EE_Error::add_error( |
759 | 759 | sprintf( |
760 | 760 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
761 | - get_class( $subsection ), |
|
761 | + get_class($subsection), |
|
762 | 762 | $subsection_name, |
763 | 763 | $this->name() |
764 | 764 | ) |
@@ -767,8 +767,8 @@ discard block |
||
767 | 767 | } |
768 | 768 | } |
769 | 769 | |
770 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
771 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
770 | + EE_Registry::instance()->load_helper('Array'); |
|
771 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
772 | 772 | |
773 | 773 | /*$subsections_before = array(); |
774 | 774 | if( $subsection_name_to_target ){ |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | $this->_subsections = $new_subsections; |
800 | 800 | } |
801 | 801 | }*/ |
802 | - if( $this->_construction_finalized ){ |
|
803 | - foreach($this->_subsections as $name => $subsection){ |
|
802 | + if ($this->_construction_finalized) { |
|
803 | + foreach ($this->_subsections as $name => $subsection) { |
|
804 | 804 | $subsection->_construct_finalize($this, $name); |
805 | 805 | } |
806 | 806 | } |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | /** |
812 | 812 | * Just gets all validatable subsections to clean their sensitive data |
813 | 813 | */ |
814 | - public function clean_sensitive_data(){ |
|
815 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
814 | + public function clean_sensitive_data() { |
|
815 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
816 | 816 | $subsection->clean_sensitive_data(); |
817 | 817 | } |
818 | 818 | } |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | /** |
823 | 823 | * @param string $form_submission_error_message |
824 | 824 | */ |
825 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
826 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
825 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
826 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | /** |
841 | 841 | * @param string $form_submission_success_message |
842 | 842 | */ |
843 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
844 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
843 | + public function set_submission_success_message($form_submission_success_message) { |
|
844 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | |
@@ -863,10 +863,10 @@ discard block |
||
863 | 863 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
864 | 864 | * @return string |
865 | 865 | */ |
866 | - public function html_name_prefix(){ |
|
867 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
868 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
869 | - }else{ |
|
866 | + public function html_name_prefix() { |
|
867 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
868 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
869 | + } else { |
|
870 | 870 | return $this->name(); |
871 | 871 | } |
872 | 872 | } |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | * was set, which is probably nothing, or the classname) |
878 | 878 | * @return string |
879 | 879 | */ |
880 | - public function name(){ |
|
880 | + public function name() { |
|
881 | 881 | $this->ensure_construct_finalized_called(); |
882 | 882 | return parent::name(); |
883 | 883 | } |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return EE_Form_Section_Proper |
888 | 888 | */ |
889 | - public function parent_section(){ |
|
889 | + public function parent_section() { |
|
890 | 890 | $this->ensure_construct_finalized_called(); |
891 | 891 | return parent::parent_section(); |
892 | 892 | } |
@@ -895,9 +895,9 @@ discard block |
||
895 | 895 | * make sure construction finalized was called, otherwise children might not be ready |
896 | 896 | * @return void |
897 | 897 | */ |
898 | - public function ensure_construct_finalized_called(){ |
|
899 | - if( ! $this->_construction_finalized ){ |
|
900 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
898 | + public function ensure_construct_finalized_called() { |
|
899 | + if ( ! $this->_construction_finalized) { |
|
900 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
@@ -909,17 +909,17 @@ discard block |
||
909 | 909 | * @param array $req_data |
910 | 910 | * @return boolean |
911 | 911 | */ |
912 | - public function form_data_present_in( $req_data = NULL ) { |
|
913 | - if( $req_data === NULL){ |
|
912 | + public function form_data_present_in($req_data = NULL) { |
|
913 | + if ($req_data === NULL) { |
|
914 | 914 | $req_data = $_POST; |
915 | 915 | } |
916 | - foreach( $this->subsections() as $subsection ) { |
|
917 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
918 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
916 | + foreach ($this->subsections() as $subsection) { |
|
917 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
918 | + if ($subsection->form_data_present_in($req_data)) { |
|
919 | 919 | return TRUE; |
920 | 920 | } |
921 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
922 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
921 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
922 | + if ($subsection->form_data_present_in($req_data)) { |
|
923 | 923 | return TRUE; |
924 | 924 | } |
925 | 925 | } |
@@ -936,14 +936,14 @@ discard block |
||
936 | 936 | */ |
937 | 937 | public function get_validation_errors_accumulated() { |
938 | 938 | $validation_errors = $this->get_validation_errors(); |
939 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
940 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
939 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
940 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
941 | 941 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
942 | 942 | } else { |
943 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
943 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
944 | 944 | } |
945 | - if( $validation_errors_on_this_subsection ){ |
|
946 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
945 | + if ($validation_errors_on_this_subsection) { |
|
946 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | return $validation_errors; |
@@ -225,7 +225,7 @@ |
||
225 | 225 | * leave this as TRUE so that the inputs will be properly configured. However, |
226 | 226 | * some client code may be ok with construction finalize being called later |
227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
228 | - * @return EE_Form_Section_Base |
|
228 | + * @return EE_Form_Section_Validatable|null |
|
229 | 229 | */ |
230 | 230 | public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
231 | 231 | if( $require_construction_to_be_finalized ){ |