@@ -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,54 +407,54 @@ discard block |
||
407 | 407 | * @param string $cur_code_span_class |
408 | 408 | * @return string the html output for the formatted money value |
409 | 409 | */ |
410 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
410 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
411 | 411 | // ensure amount was received |
412 | - if ( is_null( $amount ) ) { |
|
413 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
414 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
412 | + if (is_null($amount)) { |
|
413 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
414 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
415 | 415 | return ''; |
416 | 416 | } |
417 | 417 | //ensure amount is float |
418 | - $amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount ); |
|
419 | - $CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount ); |
|
418 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
419 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
422 | 422 | // still a number or was amount converted to a string like "free" ? |
423 | - if ( is_float( $amount_formatted )) { |
|
423 | + if (is_float($amount_formatted)) { |
|
424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
426 | 426 | // verify results |
427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
428 | 428 | // set default config country currency settings |
429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
430 | 430 | } |
431 | 431 | // format float |
432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
433 | 433 | // add formatting ? |
434 | - if ( ! $return_raw ) { |
|
434 | + if ( ! $return_raw) { |
|
435 | 435 | // add currency sign |
436 | - if( $mny->sign_b4 ){ |
|
437 | - if( $amount >= 0 ){ |
|
438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
439 | - }else{ |
|
440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
436 | + if ($mny->sign_b4) { |
|
437 | + if ($amount >= 0) { |
|
438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
439 | + } else { |
|
440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
441 | 441 | } |
442 | 442 | |
443 | - }else{ |
|
444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
443 | + } else { |
|
444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // filter to allow global setting of display_code |
448 | - $display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code ); |
|
448 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
449 | 449 | |
450 | 450 | // add currency code ? |
451 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
451 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
452 | 452 | } |
453 | 453 | // filter results |
454 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
454 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
455 | 455 | } |
456 | 456 | // clean up vars |
457 | - unset( $mny ); |
|
457 | + unset($mny); |
|
458 | 458 | // return formatted currency amount |
459 | 459 | return $amount_formatted; |
460 | 460 | } |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
470 | 470 | * @return string The localized label for the status id. |
471 | 471 | */ |
472 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
472 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
473 | 473 | /** @type EEM_Status $EEM_Status */ |
474 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
475 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
476 | - return $status[ $status_id ]; |
|
474 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
475 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
476 | + return $status[$status_id]; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | * @param string $icon |
487 | 487 | * @return string the html output for the button |
488 | 488 | */ |
489 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
490 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
491 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
489 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
490 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
491 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
492 | 492 | return $button; |
493 | 493 | } |
494 | 494 | |
@@ -505,21 +505,21 @@ discard block |
||
505 | 505 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
506 | 506 | * @return string generated link |
507 | 507 | */ |
508 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
508 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
509 | 509 | |
510 | - if ( ! $page ) |
|
511 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
510 | + if ( ! $page) |
|
511 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
512 | 512 | |
513 | - if ( ! $action ) |
|
514 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
513 | + if ( ! $action) |
|
514 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
515 | 515 | |
516 | 516 | $action = empty($action) ? 'default' : $action; |
517 | 517 | |
518 | 518 | |
519 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
520 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
521 | - $help_text = !$help_text ? '' : $help_text; |
|
522 | - 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 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
520 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
521 | + $help_text = ! $help_text ? '' : $help_text; |
|
522 | + 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>'; |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | |
@@ -531,31 +531,31 @@ discard block |
||
531 | 531 | * @param EE_Help_Tour |
532 | 532 | * @return string html |
533 | 533 | */ |
534 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
534 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
535 | 535 | $id = $tour->get_slug(); |
536 | 536 | $stops = $tour->get_stops(); |
537 | 537 | |
538 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
538 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
539 | 539 | |
540 | - foreach ( $stops as $stop ) { |
|
541 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
542 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
540 | + foreach ($stops as $stop) { |
|
541 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
542 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
543 | 543 | |
544 | 544 | //if container is set to modal then let's make sure we set the options accordingly |
545 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
545 | + if (empty($data_id) && empty($data_class)) { |
|
546 | 546 | $stop['options']['modal'] = true; |
547 | 547 | $stop['options']['expose'] = true; |
548 | 548 | } |
549 | 549 | |
550 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
551 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
550 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
551 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
552 | 552 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
553 | 553 | |
554 | 554 | //options |
555 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
555 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
556 | 556 | $options = ' data-options="'; |
557 | - foreach ( $stop['options'] as $option => $value ) { |
|
558 | - $options .= $option . ':' . $value . ';'; |
|
557 | + foreach ($stop['options'] as $option => $value) { |
|
558 | + $options .= $option.':'.$value.';'; |
|
559 | 559 | } |
560 | 560 | $options .= '"'; |
561 | 561 | } else { |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } |
564 | 564 | |
565 | 565 | //let's put all together |
566 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
566 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | $content .= '</ol>'; |
@@ -584,31 +584,31 @@ discard block |
||
584 | 584 | * @throws EE_Error |
585 | 585 | * @return string html structure for status. |
586 | 586 | */ |
587 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
588 | - if ( !is_array( $status_array ) ) |
|
589 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
587 | + public static function status_legend($status_array, $active_status = '') { |
|
588 | + if ( ! is_array($status_array)) |
|
589 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
590 | 590 | |
591 | 591 | $setup_array = array(); |
592 | - foreach ( $status_array as $item => $status ) { |
|
592 | + foreach ($status_array as $item => $status) { |
|
593 | 593 | $setup_array[$item] = array( |
594 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
595 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
594 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
595 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
596 | 596 | 'status' => $status |
597 | 597 | ); |
598 | 598 | } |
599 | 599 | |
600 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
601 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
602 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
603 | - foreach ( $setup_array as $item => $details ) { |
|
600 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
601 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
602 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
603 | + foreach ($setup_array as $item => $details) { |
|
604 | 604 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
605 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
606 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
607 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
608 | - $content .= '</dt>' . "\n"; |
|
605 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
606 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
607 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
608 | + $content .= '</dt>'."\n"; |
|
609 | 609 | } |
610 | - $content .= '</dl>' . "\n"; |
|
611 | - $content .= '</div>' . "\n"; |
|
610 | + $content .= '</dl>'."\n"; |
|
611 | + $content .= '</div>'."\n"; |
|
612 | 612 | return $content; |
613 | 613 | } |
614 | 614 | |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | * @return string |
622 | 622 | */ |
623 | 623 | public static function layout_array_as_table($data) { |
624 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
625 | - $data = (array)$data; |
|
624 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
625 | + $data = (array) $data; |
|
626 | 626 | } |
627 | 627 | ob_start(); |
628 | 628 | if (is_array($data)) { |
@@ -635,10 +635,10 @@ discard block |
||
635 | 635 | ?> |
636 | 636 | <tr> |
637 | 637 | <td> |
638 | - <?php echo $data_key;?> |
|
638 | + <?php echo $data_key; ?> |
|
639 | 639 | </td> |
640 | 640 | <td> |
641 | - <?php echo self::layout_array_as_table($data_values);?> |
|
641 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
642 | 642 | </td> |
643 | 643 | </tr> |
644 | 644 | <?php |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | <ul> |
653 | 653 | <?php |
654 | 654 | foreach ($data as $datum) { |
655 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
655 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
656 | 656 | }?> |
657 | 657 | </ul> |
658 | 658 | <?php |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
686 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
685 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
686 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | |
@@ -707,13 +707,13 @@ discard block |
||
707 | 707 | * ) |
708 | 708 | * @return string |
709 | 709 | */ |
710 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
710 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
711 | 711 | $page_links = array(); |
712 | 712 | $disable_first = $disable_last = ''; |
713 | 713 | $total_items = (int) $total_items; |
714 | 714 | $per_page = (int) $per_page; |
715 | 715 | $current = (int) $current; |
716 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
716 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
717 | 717 | |
718 | 718 | //filter items_label |
719 | 719 | $items_label = apply_filters( |
@@ -721,68 +721,68 @@ discard block |
||
721 | 721 | $items_label |
722 | 722 | ); |
723 | 723 | |
724 | - if ( empty( $items_label ) |
|
725 | - || ! is_array( $items_label ) |
|
726 | - || ! isset( $items_label['single'] ) |
|
727 | - || ! isset( $items_label['plural'] ) ) { |
|
724 | + if (empty($items_label) |
|
725 | + || ! is_array($items_label) |
|
726 | + || ! isset($items_label['single']) |
|
727 | + || ! isset($items_label['plural'])) { |
|
728 | 728 | $items_label = array( |
729 | - 'single' => __( '1 item', 'event_espresso' ), |
|
730 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
729 | + 'single' => __('1 item', 'event_espresso'), |
|
730 | + 'plural' => __('%s items', 'event_espresso') |
|
731 | 731 | ); |
732 | 732 | } else { |
733 | 733 | $items_label = array( |
734 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
735 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
734 | + 'single' => '1 '.esc_html($items_label['single']), |
|
735 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
736 | 736 | ); |
737 | 737 | } |
738 | 738 | |
739 | - $total_pages = ceil( $total_items / $per_page ); |
|
739 | + $total_pages = ceil($total_items / $per_page); |
|
740 | 740 | |
741 | - if ( $total_pages <= 1 ) |
|
741 | + if ($total_pages <= 1) |
|
742 | 742 | return ''; |
743 | 743 | |
744 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
744 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
745 | 745 | |
746 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
746 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
747 | 747 | |
748 | - if ( $current === 1 ) { |
|
748 | + if ($current === 1) { |
|
749 | 749 | $disable_first = ' disabled'; |
750 | 750 | } |
751 | - if ( $current == $total_pages ) { |
|
751 | + if ($current == $total_pages) { |
|
752 | 752 | $disable_last = ' disabled'; |
753 | 753 | } |
754 | 754 | |
755 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
756 | - 'first-page' . $disable_first, |
|
757 | - esc_attr__( 'Go to the first page' ), |
|
758 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
755 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
756 | + 'first-page'.$disable_first, |
|
757 | + esc_attr__('Go to the first page'), |
|
758 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
759 | 759 | '«' |
760 | 760 | ); |
761 | 761 | |
762 | 762 | $page_links[] = sprintf( |
763 | 763 | '<a class="%s" title="%s" href="%s">%s</a>', |
764 | - 'prev-page' . $disable_first, |
|
765 | - esc_attr__( 'Go to the previous page' ), |
|
766 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
764 | + 'prev-page'.$disable_first, |
|
765 | + esc_attr__('Go to the previous page'), |
|
766 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
767 | 767 | '‹' |
768 | 768 | ); |
769 | 769 | |
770 | - if ( ! $show_num_field ) { |
|
770 | + if ( ! $show_num_field) { |
|
771 | 771 | $html_current_page = $current; |
772 | 772 | } else { |
773 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
774 | - esc_attr__( 'Current page' ), |
|
773 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
774 | + esc_attr__('Current page'), |
|
775 | 775 | $current, |
776 | - strlen( $total_pages ) |
|
776 | + strlen($total_pages) |
|
777 | 777 | ); |
778 | 778 | } |
779 | 779 | |
780 | 780 | $html_total_pages = sprintf( |
781 | 781 | '<span class="total-pages">%s</span>', |
782 | - number_format_i18n( $total_pages ) |
|
782 | + number_format_i18n($total_pages) |
|
783 | 783 | ); |
784 | 784 | $page_links[] = sprintf( |
785 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
785 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
786 | 786 | $html_current_page, |
787 | 787 | $html_total_pages, |
788 | 788 | '<span class="paging-input">', |
@@ -791,29 +791,29 @@ discard block |
||
791 | 791 | |
792 | 792 | $page_links[] = sprintf( |
793 | 793 | '<a class="%s" title="%s" href="%s">%s</a>', |
794 | - 'next-page' . $disable_last, |
|
795 | - esc_attr__( 'Go to the next page' ), |
|
796 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
794 | + 'next-page'.$disable_last, |
|
795 | + esc_attr__('Go to the next page'), |
|
796 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
797 | 797 | '›' |
798 | 798 | ); |
799 | 799 | |
800 | 800 | $page_links[] = sprintf( |
801 | 801 | '<a class="%s" title="%s" href="%s">%s</a>', |
802 | - 'last-page' . $disable_last, |
|
803 | - esc_attr__( 'Go to the last page' ), |
|
804 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
802 | + 'last-page'.$disable_last, |
|
803 | + esc_attr__('Go to the last page'), |
|
804 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
805 | 805 | '»' |
806 | 806 | ); |
807 | 807 | |
808 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
808 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
809 | 809 | // set page class |
810 | - if ( $total_pages ) { |
|
810 | + if ($total_pages) { |
|
811 | 811 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
812 | 812 | } else { |
813 | 813 | $page_class = ' no-pages'; |
814 | 814 | } |
815 | 815 | |
816 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
816 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
830 | 830 | |
831 | 831 | |
832 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
832 | +if ( ! function_exists('espresso_pagination')) { |
|
833 | 833 | /** |
834 | 834 | * espresso_pagination |
835 | 835 | * |
@@ -841,21 +841,21 @@ discard block |
||
841 | 841 | $big = 999999999; // need an unlikely integer |
842 | 842 | $pagination = paginate_links( |
843 | 843 | array( |
844 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
844 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
845 | 845 | 'format' => '?paged=%#%', |
846 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
846 | + 'current' => max(1, get_query_var('paged')), |
|
847 | 847 | 'total' => $wp_query->max_num_pages, |
848 | 848 | 'show_all' => true, |
849 | 849 | 'end_size' => 10, |
850 | 850 | 'mid_size' => 6, |
851 | 851 | 'prev_next' => true, |
852 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
853 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
852 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
853 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
854 | 854 | 'type' => 'plain', |
855 | 855 | 'add_args' => false, |
856 | 856 | 'add_fragment' => '' |
857 | 857 | ) |
858 | 858 | ); |
859 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
859 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | \ 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 | /** |
@@ -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 |
@@ -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,6 +1,7 @@ |
||
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 | 6 | * EE_Form_Section_HTML |
6 | 7 | * HTML to be laid out like a proper subsection |
@@ -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) 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 |
@@ -69,49 +69,49 @@ discard block |
||
69 | 69 | * } @see EE_Form_Section_Validatable::__construct() |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - public function __construct( $options_array = array() ){ |
|
73 | - $options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
72 | + public function __construct($options_array = array()) { |
|
73 | + $options_array = (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 | 100 | //ok so we are definitely going to want the forms JS, |
101 | 101 | //so enqueue it or remember to enqueue it during wp_enqueue_scripts |
102 | - if( did_action( 'wp_enqueue_scripts' ) |
|
103 | - || did_action( 'admin_enqueue_scripts' ) ) { |
|
102 | + if (did_action('wp_enqueue_scripts') |
|
103 | + || did_action('admin_enqueue_scripts')) { |
|
104 | 104 | //ok so they've constructed this object after when they should have. |
105 | 105 | //just enqueue the generic form scripts and initialize the form immediately in the JS |
106 | - \EE_Form_Section_Proper::wp_enqueue_scripts( true ); |
|
106 | + \EE_Form_Section_Proper::wp_enqueue_scripts(true); |
|
107 | 107 | } else { |
108 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
109 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
108 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
109 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
110 | 110 | } |
111 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
111 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
112 | 112 | |
113 | - if( isset( $options_array[ 'name' ] ) ) { |
|
114 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
113 | + if (isset($options_array['name'])) { |
|
114 | + $this->_construct_finalize(null, $options_array['name']); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | * @param string $name |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
127 | + public function _construct_finalize($parent_form_section, $name) { |
|
128 | 128 | parent::_construct_finalize($parent_form_section, $name); |
129 | 129 | $this->_set_default_name_if_empty(); |
130 | 130 | $this->_set_default_html_id_if_empty(); |
131 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
132 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
133 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
131 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
132 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
133 | + $subsection->_construct_finalize($this, $subsection_name); |
|
134 | 134 | } else { |
135 | 135 | throw new EE_Error( |
136 | 136 | sprintf( |
137 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
137 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
138 | 138 | $subsection_name, |
139 | 139 | get_class($this), |
140 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
140 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
141 | 141 | ) |
142 | 142 | ); |
143 | 143 | } |
144 | 144 | } |
145 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
145 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * Gets the layout strategy for this form section |
152 | 152 | * @return EE_Form_Section_Layout_Base |
153 | 153 | */ |
154 | - public function get_layout_strategy(){ |
|
154 | + public function get_layout_strategy() { |
|
155 | 155 | return $this->_layout_strategy; |
156 | 156 | } |
157 | 157 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param EE_Form_Input_Base $input |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function get_html_for_input($input){ |
|
166 | + public function get_html_for_input($input) { |
|
167 | 167 | return $this->_layout_strategy->layout_input($input); |
168 | 168 | } |
169 | 169 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param null $form_data |
177 | 177 | * @return boolean |
178 | 178 | */ |
179 | - public function was_submitted($form_data = NULL){ |
|
179 | + public function was_submitted($form_data = NULL) { |
|
180 | 180 | return $this->form_data_present_in($form_data); |
181 | 181 | } |
182 | 182 | |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | * (eg you validated the data then stored it in the DB) you may want to skip this step. |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
205 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
206 | - if( $req_data === NULL){ |
|
207 | - $req_data = array_merge( $_GET, $_POST ); |
|
204 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
205 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
206 | + if ($req_data === NULL) { |
|
207 | + $req_data = array_merge($_GET, $_POST); |
|
208 | 208 | } |
209 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
209 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
210 | 210 | $this->_normalize($req_data); |
211 | - if( $validate ){ |
|
211 | + if ($validate) { |
|
212 | 212 | $this->_validate(); |
213 | 213 | } |
214 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
214 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * the value being an array formatted in teh same way |
225 | 225 | * @param array $default_data |
226 | 226 | */ |
227 | - public function populate_defaults($default_data){ |
|
228 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
229 | - if(isset($default_data[$subsection_name])){ |
|
230 | - if($subsection instanceof EE_Form_Input_Base){ |
|
227 | + public function populate_defaults($default_data) { |
|
228 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
229 | + if (isset($default_data[$subsection_name])) { |
|
230 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
231 | 231 | $subsection->set_default($default_data[$subsection_name]); |
232 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
232 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
233 | 233 | $subsection->populate_defaults($default_data[$subsection_name]); |
234 | 234 | } |
235 | 235 | } |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @return EE_Form_Section_Base |
252 | 252 | * @throws \EE_Error |
253 | 253 | */ |
254 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
255 | - if( $require_construction_to_be_finalized ){ |
|
254 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
255 | + if ($require_construction_to_be_finalized) { |
|
256 | 256 | $this->ensure_construct_finalized_called(); |
257 | 257 | } |
258 | 258 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * Gets all the validatable subsections of this form section |
265 | 265 | * @return EE_Form_Section_Validatable[] |
266 | 266 | */ |
267 | - public function get_validatable_subsections(){ |
|
267 | + public function get_validatable_subsections() { |
|
268 | 268 | $validatable_subsections = array(); |
269 | - foreach($this->subsections() as $name=>$obj){ |
|
270 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
269 | + foreach ($this->subsections() as $name=>$obj) { |
|
270 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
271 | 271 | $validatable_subsections[$name] = $obj; |
272 | 272 | } |
273 | 273 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @return EE_Form_Input_Base |
288 | 288 | * @throws EE_Error |
289 | 289 | */ |
290 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
290 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
291 | 291 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
292 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
293 | - 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'))); |
|
292 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
293 | + 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'))); |
|
294 | 294 | } |
295 | 295 | return $subsection; |
296 | 296 | } |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | * @return EE_Form_Section_Proper |
309 | 309 | * @throws EE_Error |
310 | 310 | */ |
311 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
312 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
313 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
314 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
311 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
312 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
313 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
314 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
315 | 315 | } |
316 | 316 | return $subsection; |
317 | 317 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @return mixed depending on the input's type and its normalization strategy |
327 | 327 | * @throws \EE_Error |
328 | 328 | */ |
329 | - public function get_input_value($name){ |
|
329 | + public function get_input_value($name) { |
|
330 | 330 | $input = $this->get_input($name); |
331 | 331 | return $input->normalized_value(); |
332 | 332 | } |
@@ -339,16 +339,16 @@ discard block |
||
339 | 339 | * @return boolean |
340 | 340 | */ |
341 | 341 | public function is_valid() { |
342 | - if( ! $this->has_received_submission()){ |
|
342 | + if ( ! $this->has_received_submission()) { |
|
343 | 343 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
344 | 344 | } |
345 | - if( ! parent::is_valid()){ |
|
345 | + if ( ! parent::is_valid()) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | //ok so no errors general to this entire form section. so let's check the subsections |
349 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
350 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){ |
|
351 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
349 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
350 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') { |
|
351 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
352 | 352 | return false; |
353 | 353 | } |
354 | 354 | } |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * gets teh default name of this form section if none is specified |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - protected function _set_default_name_if_empty(){ |
|
365 | - if( ! $this->_name ){ |
|
364 | + protected function _set_default_name_if_empty() { |
|
365 | + if ( ! $this->_name) { |
|
366 | 366 | $classname = get_class($this); |
367 | 367 | $default_name = str_replace("EE_", "", $classname); |
368 | - $this->_name = $default_name; |
|
368 | + $this->_name = $default_name; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * and get_html when you are about to display the form. |
381 | 381 | * @throws \EE_Error |
382 | 382 | */ |
383 | - public function get_html_and_js(){ |
|
383 | + public function get_html_and_js() { |
|
384 | 384 | //no doing_it_wrong yet because we ourselves are still doing it wrong... |
385 | 385 | //and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts" |
386 | 386 | $this->enqueue_js(); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @return string |
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | - public function get_html(){ |
|
398 | + public function get_html() { |
|
399 | 399 | $this->ensure_construct_finalized_called(); |
400 | 400 | return $this->_layout_strategy->layout_form(); |
401 | 401 | } |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @return string |
409 | 409 | * @throws \EE_Error |
410 | 410 | */ |
411 | - public function enqueue_js(){ |
|
411 | + public function enqueue_js() { |
|
412 | 412 | $this->_enqueue_and_localize_form_js(); |
413 | - foreach( $this->subsections() as $subsection ) { |
|
413 | + foreach ($this->subsections() as $subsection) { |
|
414 | 414 | $subsection->enqueue_js(); |
415 | 415 | } |
416 | 416 | } |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not |
428 | 428 | * @return void |
429 | 429 | */ |
430 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){ |
|
431 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
432 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
433 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ? true : false ) ); |
|
430 | + public static function wp_enqueue_scripts($init_form_validation_automatically = true) { |
|
431 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
432 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE); |
|
433 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically ? true : false)); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -442,14 +442,14 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @throws \EE_Error |
444 | 444 | */ |
445 | - public function _enqueue_and_localize_form_js(){ |
|
445 | + public function _enqueue_and_localize_form_js() { |
|
446 | 446 | $this->ensure_construct_finalized_called(); |
447 | 447 | //actually, we don't want to localize just yet. There may be other forms on the page. |
448 | 448 | //so we need to add our form section data to a static variable accessible by all form sections |
449 | 449 | //and localize it just before the footer |
450 | 450 | $this->localize_validation_rules(); |
451 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
452 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
451 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
452 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | * @return void |
462 | 462 | * @throws \EE_Error |
463 | 463 | */ |
464 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
464 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
465 | 465 | // 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 |
466 | - if ( $return_for_subsection || ! $this->parent_section() ) { |
|
467 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
468 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
466 | + if ($return_for_subsection || ! $this->parent_section()) { |
|
467 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
468 | + 'form_section_id'=> $this->html_id(TRUE), |
|
469 | 469 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
470 | 470 | 'other_data' => $this->get_other_js_data(), |
471 | 471 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -481,9 +481,9 @@ discard block |
||
481 | 481 | * @param array $form_other_js_data |
482 | 482 | * @return array |
483 | 483 | */ |
484 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
485 | - foreach( $this->subsections() as $subsection ) { |
|
486 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
484 | + public function get_other_js_data($form_other_js_data = array()) { |
|
485 | + foreach ($this->subsections() as $subsection) { |
|
486 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
487 | 487 | } |
488 | 488 | return $form_other_js_data; |
489 | 489 | } |
@@ -494,12 +494,12 @@ discard block |
||
494 | 494 | * Keys are their form names, and values are the inputs themselves |
495 | 495 | * @return EE_Form_Input_Base |
496 | 496 | */ |
497 | - public function inputs_in_subsections(){ |
|
497 | + public function inputs_in_subsections() { |
|
498 | 498 | $inputs = array(); |
499 | - foreach($this->subsections() as $subsection){ |
|
500 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
501 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
502 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
499 | + foreach ($this->subsections() as $subsection) { |
|
500 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
501 | + $inputs[$subsection->html_name()] = $subsection; |
|
502 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
503 | 503 | $inputs += $subsection->inputs_in_subsections(); |
504 | 504 | } |
505 | 505 | } |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | * and values are a string of all their validation errors |
513 | 513 | * @return string[] |
514 | 514 | */ |
515 | - public function subsection_validation_errors_by_html_name(){ |
|
515 | + public function subsection_validation_errors_by_html_name() { |
|
516 | 516 | $inputs = $this->inputs(); |
517 | 517 | $errors = array(); |
518 | - foreach( $inputs as $form_input ){ |
|
519 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
520 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
518 | + foreach ($inputs as $form_input) { |
|
519 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
520 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | return $errors; |
@@ -529,16 +529,16 @@ discard block |
||
529 | 529 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
530 | 530 | * Should be setup by each form during the _enqueues_and_localize_form_js |
531 | 531 | */ |
532 | - public static function localize_script_for_all_forms(){ |
|
532 | + public static function localize_script_for_all_forms() { |
|
533 | 533 | //allow inputs and stuff to hook in their JS and stuff here |
534 | 534 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
535 | 535 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
536 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
536 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
537 | 537 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
538 | 538 | : 'wp_default'; |
539 | 539 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
540 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
541 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
540 | + wp_enqueue_script('ee_form_section_validation'); |
|
541 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | /** |
547 | 547 | * ensure_scripts_localized |
548 | 548 | */ |
549 | - public function ensure_scripts_localized(){ |
|
550 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
549 | + public function ensure_scripts_localized() { |
|
550 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
551 | 551 | $this->_enqueue_and_localize_form_js(); |
552 | 552 | } |
553 | 553 | } |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | * is that the key here should be the same as the custom validation rule put in the JS file |
560 | 560 | * @return array keys are custom validation rules, and values are internationalized strings |
561 | 561 | */ |
562 | - private static function _get_localized_error_messages(){ |
|
562 | + private static function _get_localized_error_messages() { |
|
563 | 563 | return array( |
564 | 564 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
565 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
565 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
566 | 566 | ); |
567 | 567 | } |
568 | 568 | |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
591 | 591 | * @return array |
592 | 592 | */ |
593 | - public function get_jquery_validation_rules(){ |
|
593 | + public function get_jquery_validation_rules() { |
|
594 | 594 | $jquery_validation_rules = array(); |
595 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
596 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
595 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
596 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
597 | 597 | } |
598 | 598 | return $jquery_validation_rules; |
599 | 599 | } |
@@ -608,11 +608,11 @@ discard block |
||
608 | 608 | protected function _normalize($req_data) { |
609 | 609 | $this->_received_submission = TRUE; |
610 | 610 | $this->_validation_errors = array(); |
611 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
612 | - try{ |
|
611 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
612 | + try { |
|
613 | 613 | $subsection->_normalize($req_data); |
614 | - }catch( EE_Validation_Error $e ){ |
|
615 | - $subsection->add_validation_error( $e ); |
|
614 | + } catch (EE_Validation_Error $e) { |
|
615 | + $subsection->add_validation_error($e); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | } |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | * calling parent::_validate() first. |
627 | 627 | */ |
628 | 628 | protected function _validate() { |
629 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
630 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
631 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
629 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
630 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
631 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
632 | 632 | } |
633 | 633 | $subsection->_validate(); |
634 | 634 | } |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | * Gets all the validated inputs for the form section |
641 | 641 | * @return array |
642 | 642 | */ |
643 | - public function valid_data(){ |
|
643 | + public function valid_data() { |
|
644 | 644 | $inputs = array(); |
645 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
646 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
647 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
648 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
649 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
645 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
646 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
647 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
648 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
649 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | return $inputs; |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | * Gets all the inputs on this form section |
659 | 659 | * @return EE_Form_Input_Base[] |
660 | 660 | */ |
661 | - public function inputs(){ |
|
661 | + public function inputs() { |
|
662 | 662 | $inputs = array(); |
663 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
664 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
665 | - $inputs[ $subsection_name ] = $subsection; |
|
663 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
664 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
665 | + $inputs[$subsection_name] = $subsection; |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | return $inputs; |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | * Gets all the subsections which are a proper form |
675 | 675 | * @return EE_Form_Section_Proper[] |
676 | 676 | */ |
677 | - public function subforms(){ |
|
677 | + public function subforms() { |
|
678 | 678 | $form_sections = array(); |
679 | - foreach($this->subsections() as $name=>$obj){ |
|
680 | - if($obj instanceof EE_Form_Section_Proper){ |
|
679 | + foreach ($this->subsections() as $name=>$obj) { |
|
680 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
681 | 681 | $form_sections[$name] = $obj; |
682 | 682 | } |
683 | 683 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * if you only want form inputs or proper form sections. |
693 | 693 | * @return EE_Form_Section_Proper[] |
694 | 694 | */ |
695 | - public function subsections(){ |
|
695 | + public function subsections() { |
|
696 | 696 | $this->ensure_construct_finalized_called(); |
697 | 697 | return $this->_subsections; |
698 | 698 | } |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | * it can be a multidimensional array where keys are always subsection names and values are either the |
711 | 711 | * input's normalized value, or an array like the top-level array |
712 | 712 | */ |
713 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
714 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
713 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
714 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | * it can be a multidimensional array where keys are always subsection names and values are either the |
728 | 728 | * input's normalized value, or an array like the top-level array |
729 | 729 | */ |
730 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
731 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
730 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
731 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | /** |
@@ -741,17 +741,17 @@ discard block |
||
741 | 741 | * it can be a multidimensional array where keys are always subsection names and values are either the |
742 | 742 | * input's normalized value, or an array like the top-level array |
743 | 743 | */ |
744 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
744 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
745 | 745 | $input_values = array(); |
746 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
747 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
748 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
749 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
750 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
751 | - if( $flatten ) { |
|
752 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
746 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
747 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
748 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
749 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
750 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
751 | + if ($flatten) { |
|
752 | + $input_values = array_merge($input_values, $subform_input_values); |
|
753 | 753 | } else { |
754 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
754 | + $input_values[$subsection_name] = $subform_input_values; |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | } |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | * @return boolean |
768 | 768 | * @throws \EE_Error |
769 | 769 | */ |
770 | - public function has_received_submission(){ |
|
770 | + public function has_received_submission() { |
|
771 | 771 | $this->ensure_construct_finalized_called(); |
772 | 772 | return $this->_received_submission; |
773 | 773 | } |
@@ -780,8 +780,8 @@ discard block |
||
780 | 780 | * @param array $inputs_to_exclude values are the input names |
781 | 781 | * @return void |
782 | 782 | */ |
783 | - public function exclude($inputs_to_exclude = array()){ |
|
784 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
783 | + public function exclude($inputs_to_exclude = array()) { |
|
784 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
785 | 785 | unset($this->_subsections[$input_to_exclude_name]); |
786 | 786 | } |
787 | 787 | } |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | * @param array $inputs_to_hide |
793 | 793 | * @throws \EE_Error |
794 | 794 | */ |
795 | - public function hide($inputs_to_hide= array()){ |
|
796 | - foreach($inputs_to_hide as $input_to_hide){ |
|
795 | + public function hide($inputs_to_hide = array()) { |
|
796 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
797 | 797 | $input = $this->get_input($input_to_hide); |
798 | 798 | |
799 | 799 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | * @return void |
819 | 819 | * @throws \EE_Error |
820 | 820 | */ |
821 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
822 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
823 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
821 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
822 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
823 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
824 | 824 | EE_Error::add_error( |
825 | 825 | sprintf( |
826 | 826 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
827 | - get_class( $subsection ), |
|
827 | + get_class($subsection), |
|
828 | 828 | $subsection_name, |
829 | 829 | $this->name() |
830 | 830 | ) |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
836 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
837 | 837 | |
838 | 838 | /*$subsections_before = array(); |
839 | 839 | if( $subsection_name_to_target ){ |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | $this->_subsections = $new_subsections; |
865 | 865 | } |
866 | 866 | }*/ |
867 | - if( $this->_construction_finalized ){ |
|
868 | - foreach($this->_subsections as $name => $subsection){ |
|
867 | + if ($this->_construction_finalized) { |
|
868 | + foreach ($this->_subsections as $name => $subsection) { |
|
869 | 869 | $subsection->_construct_finalize($this, $name); |
870 | 870 | } |
871 | 871 | } |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | /** |
877 | 877 | * Just gets all validatable subsections to clean their sensitive data |
878 | 878 | */ |
879 | - public function clean_sensitive_data(){ |
|
880 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
879 | + public function clean_sensitive_data() { |
|
880 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
881 | 881 | $subsection->clean_sensitive_data(); |
882 | 882 | } |
883 | 883 | } |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | /** |
888 | 888 | * @param string $form_submission_error_message |
889 | 889 | */ |
890 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
891 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
890 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
891 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | /** |
906 | 906 | * @param string $form_submission_success_message |
907 | 907 | */ |
908 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
909 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
908 | + public function set_submission_success_message($form_submission_success_message) { |
|
909 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | |
@@ -929,10 +929,10 @@ discard block |
||
929 | 929 | * @return string |
930 | 930 | * @throws \EE_Error |
931 | 931 | */ |
932 | - public function html_name_prefix(){ |
|
933 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
934 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
935 | - }else{ |
|
932 | + public function html_name_prefix() { |
|
933 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
934 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
935 | + } else { |
|
936 | 936 | return $this->name(); |
937 | 937 | } |
938 | 938 | } |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * @return string |
948 | 948 | * @throws \EE_Error |
949 | 949 | */ |
950 | - public function name(){ |
|
950 | + public function name() { |
|
951 | 951 | $this->ensure_construct_finalized_called(); |
952 | 952 | return parent::name(); |
953 | 953 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | * @return EE_Form_Section_Proper |
959 | 959 | * @throws \EE_Error |
960 | 960 | */ |
961 | - public function parent_section(){ |
|
961 | + public function parent_section() { |
|
962 | 962 | $this->ensure_construct_finalized_called(); |
963 | 963 | return parent::parent_section(); |
964 | 964 | } |
@@ -971,9 +971,9 @@ discard block |
||
971 | 971 | * @return void |
972 | 972 | * @throws \EE_Error |
973 | 973 | */ |
974 | - public function ensure_construct_finalized_called(){ |
|
975 | - if( ! $this->_construction_finalized ){ |
|
976 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
974 | + public function ensure_construct_finalized_called() { |
|
975 | + if ( ! $this->_construction_finalized) { |
|
976 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | |
@@ -985,17 +985,17 @@ discard block |
||
985 | 985 | * @param array $req_data |
986 | 986 | * @return boolean |
987 | 987 | */ |
988 | - public function form_data_present_in( $req_data = NULL ) { |
|
989 | - if( $req_data === NULL){ |
|
988 | + public function form_data_present_in($req_data = NULL) { |
|
989 | + if ($req_data === NULL) { |
|
990 | 990 | $req_data = $_POST; |
991 | 991 | } |
992 | - foreach( $this->subsections() as $subsection ) { |
|
993 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
994 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
992 | + foreach ($this->subsections() as $subsection) { |
|
993 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
994 | + if ($subsection->form_data_present_in($req_data)) { |
|
995 | 995 | return TRUE; |
996 | 996 | } |
997 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
998 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
997 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
998 | + if ($subsection->form_data_present_in($req_data)) { |
|
999 | 999 | return TRUE; |
1000 | 1000 | } |
1001 | 1001 | } |
@@ -1012,14 +1012,14 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | public function get_validation_errors_accumulated() { |
1014 | 1014 | $validation_errors = $this->get_validation_errors(); |
1015 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
1016 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
1015 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1016 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
1017 | 1017 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
1018 | 1018 | } else { |
1019 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1019 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1020 | 1020 | } |
1021 | - if( $validation_errors_on_this_subsection ){ |
|
1022 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
1021 | + if ($validation_errors_on_this_subsection) { |
|
1022 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | return $validation_errors; |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
1042 | 1042 | * @return EE_Form_Section_Base |
1043 | 1043 | */ |
1044 | - public function find_section_from_path( $form_section_path ) { |
|
1044 | + public function find_section_from_path($form_section_path) { |
|
1045 | 1045 | //check if we can find the input from purely going straight up the tree |
1046 | - $input = parent::find_section_from_path( $form_section_path ); |
|
1047 | - if( $input instanceof EE_Form_Section_Base ) { |
|
1046 | + $input = parent::find_section_from_path($form_section_path); |
|
1047 | + if ($input instanceof EE_Form_Section_Base) { |
|
1048 | 1048 | return $input; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
1052 | - if( $next_slash_pos !== false ) { |
|
1053 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
1054 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
1051 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
1052 | + if ($next_slash_pos !== false) { |
|
1053 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
1054 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
1055 | 1055 | } else { |
1056 | 1056 | $child_section_name = $form_section_path; |
1057 | 1057 | $subpath = ''; |
1058 | 1058 | } |
1059 | - $child_section = $this->get_subsection( $child_section_name ); |
|
1060 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
1061 | - return $child_section->find_section_from_path( $subpath ); |
|
1059 | + $child_section = $this->get_subsection($child_section_name); |
|
1060 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
1061 | + return $child_section->find_section_from_path($subpath); |
|
1062 | 1062 | } else { |
1063 | 1063 | return null; |
1064 | 1064 | } |
@@ -248,7 +248,7 @@ |
||
248 | 248 | * with construction finalize being called later |
249 | 249 | * (realizing that the subsections' html names |
250 | 250 | * might not be set yet, etc.) |
251 | - * @return EE_Form_Section_Base |
|
251 | + * @return EE_Form_Section_Validatable|null |
|
252 | 252 | * @throws \EE_Error |
253 | 253 | */ |
254 | 254 | public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |