@@ -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,80 +210,80 @@ 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 | EE_Registry::instance()->load_helper('File'); |
| 239 | 239 | // loop through $templates |
| 240 | - foreach ( $templates as $template ) { |
|
| 240 | + foreach ($templates as $template) { |
|
| 241 | 241 | // normalize directory separators |
| 242 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
| 243 | - $file_name = basename( $template ); |
|
| 244 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
| 242 | + $template = EEH_File::standardise_directory_separators($template); |
|
| 243 | + $file_name = basename($template); |
|
| 244 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
| 245 | 245 | // while looping through all template folder paths |
| 246 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
| 246 | + foreach ($template_folder_paths as $template_folder_path) { |
|
| 247 | 247 | // normalize directory separators |
| 248 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
| 248 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
| 249 | 249 | // determine if any common base path exists between the two paths |
| 250 | 250 | $common_base_path = EEH_Template::_find_common_base_path( |
| 251 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
| 251 | + array($template_folder_path, $template_path_minus_file_name) |
|
| 252 | 252 | ); |
| 253 | - if ( $common_base_path !== '' ) { |
|
| 253 | + if ($common_base_path !== '') { |
|
| 254 | 254 | // both paths have a common base, so just tack the filename onto our search path |
| 255 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
| 255 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
| 256 | 256 | } else { |
| 257 | 257 | // no common base path, so let's just concatenate |
| 258 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
| 258 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
| 259 | 259 | } |
| 260 | 260 | // build up our template locations array by adding our resolved paths |
| 261 | 261 | $full_template_paths[] = $resolved_path; |
| 262 | 262 | } |
| 263 | 263 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
| 264 | - array_unshift( $full_template_paths, $template ); |
|
| 264 | + array_unshift($full_template_paths, $template); |
|
| 265 | 265 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
| 266 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
| 266 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
| 267 | 267 | } |
| 268 | 268 | // filter final array of full template paths |
| 269 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
| 269 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
| 270 | 270 | // now loop through our final array of template location paths and check each location |
| 271 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
| 272 | - if ( is_readable( $full_template_path )) { |
|
| 273 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
| 271 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
| 272 | + if (is_readable($full_template_path)) { |
|
| 273 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
| 274 | 274 | break; |
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | // if we got it and you want to see it... |
| 279 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
| 280 | - if ( $return_string ) { |
|
| 281 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 279 | + if ($template_path && $load && ! $check_if_custom) { |
|
| 280 | + if ($return_string) { |
|
| 281 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 282 | 282 | } else { |
| 283 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
| 283 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
| 286 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | |
@@ -296,21 +296,21 @@ discard block |
||
| 296 | 296 | * @param array $paths |
| 297 | 297 | * @return string |
| 298 | 298 | */ |
| 299 | - protected static function _find_common_base_path( $paths ) { |
|
| 299 | + protected static function _find_common_base_path($paths) { |
|
| 300 | 300 | $last_offset = 0; |
| 301 | 301 | $common_base_path = ''; |
| 302 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
| 302 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
| 303 | 303 | $dir_length = $index - $last_offset + 1; |
| 304 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
| 305 | - foreach ( $paths as $path ) { |
|
| 306 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
| 304 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
| 305 | + foreach ($paths as $path) { |
|
| 306 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
| 307 | 307 | return $common_base_path; |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | $common_base_path .= $directory; |
| 311 | 311 | $last_offset = $index + 1; |
| 312 | 312 | } |
| 313 | - return substr( $common_base_path, 0, -1 ); |
|
| 313 | + return substr($common_base_path, 0, -1); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
| 323 | 323 | * @return mixed string |
| 324 | 324 | */ |
| 325 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
| 325 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
| 326 | 326 | //require the template validator for verifying variables are set according to how the template requires |
| 327 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
| 327 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | 330 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -335,26 +335,26 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @since 4.6.0 |
| 337 | 337 | */ |
| 338 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
| 339 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
| 338 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
| 339 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
| 340 | 340 | |
| 341 | 341 | // you gimme nuttin - YOU GET NUTTIN !! |
| 342 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
| 342 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
| 343 | 343 | return ''; |
| 344 | 344 | } |
| 345 | 345 | // if $template_args are not in an array, then make it so |
| 346 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
| 347 | - $template_args = array( $template_args ); |
|
| 346 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
| 347 | + $template_args = array($template_args); |
|
| 348 | 348 | } |
| 349 | - extract( (array) $template_args); |
|
| 349 | + extract((array) $template_args); |
|
| 350 | 350 | |
| 351 | - if ( $return_string ) { |
|
| 351 | + if ($return_string) { |
|
| 352 | 352 | // because we want to return a string, we are going to capture the output |
| 353 | 353 | ob_start(); |
| 354 | - include( $template_path ); |
|
| 354 | + include($template_path); |
|
| 355 | 355 | return ob_get_clean(); |
| 356 | 356 | } else { |
| 357 | - include( $template_path ); |
|
| 357 | + include($template_path); |
|
| 358 | 358 | } |
| 359 | 359 | return ''; |
| 360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
| 372 | 372 | * @param string $suffix added to the end of the generated class |
| 373 | 373 | * @return string |
| 374 | 374 | */ |
| 375 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 375 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 376 | 376 | // in the beginning... |
| 377 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
| 377 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
| 378 | 378 | // da muddle |
| 379 | 379 | $class = ''; |
| 380 | 380 | // the end |
| 381 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
| 381 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
| 382 | 382 | // is the passed object an EE object ? |
| 383 | - if ( $object instanceof EE_Base_Class ) { |
|
| 383 | + if ($object instanceof EE_Base_Class) { |
|
| 384 | 384 | // grab the exact type of object |
| 385 | - $obj_class = get_class( $object ); |
|
| 385 | + $obj_class = get_class($object); |
|
| 386 | 386 | // depending on the type of object... |
| 387 | - switch ( $obj_class ) { |
|
| 387 | + switch ($obj_class) { |
|
| 388 | 388 | // no specifics just yet... |
| 389 | 389 | default : |
| 390 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
| 391 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
| 390 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
| 391 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
| 392 | 392 | |
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | - return $prefix . $class . $suffix; |
|
| 395 | + return $prefix.$class.$suffix; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | |
@@ -408,50 +408,50 @@ discard block |
||
| 408 | 408 | * @param string $cur_code_span_class |
| 409 | 409 | * @return string the html output for the formatted money value |
| 410 | 410 | */ |
| 411 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
| 411 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
| 412 | 412 | // ensure amount was received |
| 413 | - if ( is_null( $amount ) ) { |
|
| 414 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
| 415 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 413 | + if (is_null($amount)) { |
|
| 414 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
| 415 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 416 | 416 | return ''; |
| 417 | 417 | } |
| 418 | 418 | //ensure amount is float |
| 419 | 419 | $amount = (float) $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 | // add currency code ? |
| 448 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
| 448 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
| 449 | 449 | } |
| 450 | 450 | // filter results |
| 451 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
| 451 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
| 452 | 452 | } |
| 453 | 453 | // clean up vars |
| 454 | - unset( $mny ); |
|
| 454 | + unset($mny); |
|
| 455 | 455 | // return formatted currency amount |
| 456 | 456 | return $amount_formatted; |
| 457 | 457 | } |
@@ -466,11 +466,11 @@ discard block |
||
| 466 | 466 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
| 467 | 467 | * @return string The localized label for the status id. |
| 468 | 468 | */ |
| 469 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
| 469 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
| 470 | 470 | /** @type EEM_Status $EEM_Status */ |
| 471 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
| 472 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
| 473 | - return $status[ $status_id ]; |
|
| 471 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
| 472 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
| 473 | + return $status[$status_id]; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | |
@@ -483,9 +483,9 @@ discard block |
||
| 483 | 483 | * @param string $icon |
| 484 | 484 | * @return string the html output for the button |
| 485 | 485 | */ |
| 486 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
| 487 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
| 488 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
| 486 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
| 487 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
| 488 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
| 489 | 489 | return $button; |
| 490 | 490 | } |
| 491 | 491 | |
@@ -502,21 +502,21 @@ discard block |
||
| 502 | 502 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
| 503 | 503 | * @return string generated link |
| 504 | 504 | */ |
| 505 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
| 505 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
| 506 | 506 | |
| 507 | - if ( ! $page ) |
|
| 508 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 507 | + if ( ! $page) |
|
| 508 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
| 509 | 509 | |
| 510 | - if ( ! $action ) |
|
| 511 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 510 | + if ( ! $action) |
|
| 511 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
| 512 | 512 | |
| 513 | 513 | $action = empty($action) ? 'default' : $action; |
| 514 | 514 | |
| 515 | 515 | |
| 516 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
| 517 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 518 | - $help_text = !$help_text ? '' : $help_text; |
|
| 519 | - 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>'; |
|
| 516 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
| 517 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 518 | + $help_text = ! $help_text ? '' : $help_text; |
|
| 519 | + 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>'; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,31 +528,31 @@ discard block |
||
| 528 | 528 | * @param EE_Help_Tour |
| 529 | 529 | * @return string html |
| 530 | 530 | */ |
| 531 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
| 531 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
| 532 | 532 | $id = $tour->get_slug(); |
| 533 | 533 | $stops = $tour->get_stops(); |
| 534 | 534 | |
| 535 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
| 535 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
| 536 | 536 | |
| 537 | - foreach ( $stops as $stop ) { |
|
| 538 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
| 539 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
| 537 | + foreach ($stops as $stop) { |
|
| 538 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
| 539 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
| 540 | 540 | |
| 541 | 541 | //if container is set to modal then let's make sure we set the options accordingly |
| 542 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
| 542 | + if (empty($data_id) && empty($data_class)) { |
|
| 543 | 543 | $stop['options']['modal'] = true; |
| 544 | 544 | $stop['options']['expose'] = true; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
| 548 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
| 547 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
| 548 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
| 549 | 549 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
| 550 | 550 | |
| 551 | 551 | //options |
| 552 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
| 552 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
| 553 | 553 | $options = ' data-options="'; |
| 554 | - foreach ( $stop['options'] as $option => $value ) { |
|
| 555 | - $options .= $option . ':' . $value . ';'; |
|
| 554 | + foreach ($stop['options'] as $option => $value) { |
|
| 555 | + $options .= $option.':'.$value.';'; |
|
| 556 | 556 | } |
| 557 | 557 | $options .= '"'; |
| 558 | 558 | } else { |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | //let's put all together |
| 563 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
| 563 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | $content .= '</ol>'; |
@@ -581,31 +581,31 @@ discard block |
||
| 581 | 581 | * @throws EE_Error |
| 582 | 582 | * @return string html structure for status. |
| 583 | 583 | */ |
| 584 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
| 585 | - if ( !is_array( $status_array ) ) |
|
| 586 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 584 | + public static function status_legend($status_array, $active_status = '') { |
|
| 585 | + if ( ! is_array($status_array)) |
|
| 586 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
| 587 | 587 | |
| 588 | 588 | $setup_array = array(); |
| 589 | - foreach ( $status_array as $item => $status ) { |
|
| 589 | + foreach ($status_array as $item => $status) { |
|
| 590 | 590 | $setup_array[$item] = array( |
| 591 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
| 592 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
| 591 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
| 592 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
| 593 | 593 | 'status' => $status |
| 594 | 594 | ); |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
| 598 | - $content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
| 599 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
| 600 | - foreach ( $setup_array as $item => $details ) { |
|
| 597 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
| 598 | + $content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
| 599 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
| 600 | + foreach ($setup_array as $item => $details) { |
|
| 601 | 601 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
| 602 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
| 603 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
| 604 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
| 605 | - $content .= '</dt>' . "\n"; |
|
| 602 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
| 603 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
| 604 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
| 605 | + $content .= '</dt>'."\n"; |
|
| 606 | 606 | } |
| 607 | - $content .= '</dl>' . "\n"; |
|
| 608 | - $content .= '</div>' . "\n"; |
|
| 607 | + $content .= '</dl>'."\n"; |
|
| 608 | + $content .= '</div>'."\n"; |
|
| 609 | 609 | return $content; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -618,8 +618,8 @@ discard block |
||
| 618 | 618 | * @return string |
| 619 | 619 | */ |
| 620 | 620 | public static function layout_array_as_table($data) { |
| 621 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
| 622 | - $data = (array)$data; |
|
| 621 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 622 | + $data = (array) $data; |
|
| 623 | 623 | } |
| 624 | 624 | EE_Registry::instance()->load_helper('Array'); |
| 625 | 625 | ob_start(); |
@@ -633,10 +633,10 @@ discard block |
||
| 633 | 633 | ?> |
| 634 | 634 | <tr> |
| 635 | 635 | <td> |
| 636 | - <?php echo $data_key;?> |
|
| 636 | + <?php echo $data_key; ?> |
|
| 637 | 637 | </td> |
| 638 | 638 | <td> |
| 639 | - <?php echo self::layout_array_as_table($data_values);?> |
|
| 639 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
| 640 | 640 | </td> |
| 641 | 641 | </tr> |
| 642 | 642 | <?php |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | <ul> |
| 651 | 651 | <?php |
| 652 | 652 | foreach ($data as $datum) { |
| 653 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
| 653 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
| 654 | 654 | }?> |
| 655 | 655 | </ul> |
| 656 | 656 | <?php |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | * |
| 681 | 681 | * @return string |
| 682 | 682 | */ |
| 683 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 684 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
| 683 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 684 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | |
@@ -705,13 +705,13 @@ discard block |
||
| 705 | 705 | * ) |
| 706 | 706 | * @return string |
| 707 | 707 | */ |
| 708 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 708 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 709 | 709 | $page_links = array(); |
| 710 | 710 | $disable_first = $disable_last = ''; |
| 711 | 711 | $total_items = (int) $total_items; |
| 712 | 712 | $per_page = (int) $per_page; |
| 713 | 713 | $current = (int) $current; |
| 714 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
| 714 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
| 715 | 715 | |
| 716 | 716 | //filter items_label |
| 717 | 717 | $items_label = apply_filters( |
@@ -719,68 +719,68 @@ discard block |
||
| 719 | 719 | $items_label |
| 720 | 720 | ); |
| 721 | 721 | |
| 722 | - if ( empty( $items_label ) |
|
| 723 | - || ! is_array( $items_label ) |
|
| 724 | - || ! isset( $items_label['single'] ) |
|
| 725 | - || ! isset( $items_label['plural'] ) ) { |
|
| 722 | + if (empty($items_label) |
|
| 723 | + || ! is_array($items_label) |
|
| 724 | + || ! isset($items_label['single']) |
|
| 725 | + || ! isset($items_label['plural'])) { |
|
| 726 | 726 | $items_label = array( |
| 727 | - 'single' => __( '1 item', 'event_espresso' ), |
|
| 728 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
| 727 | + 'single' => __('1 item', 'event_espresso'), |
|
| 728 | + 'plural' => __('%s items', 'event_espresso') |
|
| 729 | 729 | ); |
| 730 | 730 | } else { |
| 731 | 731 | $items_label = array( |
| 732 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
| 733 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
| 732 | + 'single' => '1 '.esc_html($items_label['single']), |
|
| 733 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
| 734 | 734 | ); |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 737 | + $total_pages = ceil($total_items / $per_page); |
|
| 738 | 738 | |
| 739 | - if ( $total_pages <= 1 ) |
|
| 739 | + if ($total_pages <= 1) |
|
| 740 | 740 | return ''; |
| 741 | 741 | |
| 742 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
| 742 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
| 743 | 743 | |
| 744 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
| 744 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
| 745 | 745 | |
| 746 | - if ( $current === 1 ) { |
|
| 746 | + if ($current === 1) { |
|
| 747 | 747 | $disable_first = ' disabled'; |
| 748 | 748 | } |
| 749 | - if ( $current == $total_pages ) { |
|
| 749 | + if ($current == $total_pages) { |
|
| 750 | 750 | $disable_last = ' disabled'; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 754 | - 'first-page' . $disable_first, |
|
| 755 | - esc_attr__( 'Go to the first page' ), |
|
| 756 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
| 753 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 754 | + 'first-page'.$disable_first, |
|
| 755 | + esc_attr__('Go to the first page'), |
|
| 756 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
| 757 | 757 | '«' |
| 758 | 758 | ); |
| 759 | 759 | |
| 760 | 760 | $page_links[] = sprintf( |
| 761 | 761 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 762 | - 'prev-page' . $disable_first, |
|
| 763 | - esc_attr__( 'Go to the previous page' ), |
|
| 764 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
| 762 | + 'prev-page'.$disable_first, |
|
| 763 | + esc_attr__('Go to the previous page'), |
|
| 764 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
| 765 | 765 | '‹' |
| 766 | 766 | ); |
| 767 | 767 | |
| 768 | - if ( ! $show_num_field ) { |
|
| 768 | + if ( ! $show_num_field) { |
|
| 769 | 769 | $html_current_page = $current; |
| 770 | 770 | } else { |
| 771 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 772 | - esc_attr__( 'Current page' ), |
|
| 771 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 772 | + esc_attr__('Current page'), |
|
| 773 | 773 | $current, |
| 774 | - strlen( $total_pages ) |
|
| 774 | + strlen($total_pages) |
|
| 775 | 775 | ); |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | $html_total_pages = sprintf( |
| 779 | 779 | '<span class="total-pages">%s</span>', |
| 780 | - number_format_i18n( $total_pages ) |
|
| 780 | + number_format_i18n($total_pages) |
|
| 781 | 781 | ); |
| 782 | 782 | $page_links[] = sprintf( |
| 783 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
| 783 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
| 784 | 784 | $html_current_page, |
| 785 | 785 | $html_total_pages, |
| 786 | 786 | '<span class="paging-input">', |
@@ -789,29 +789,29 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | $page_links[] = sprintf( |
| 791 | 791 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 792 | - 'next-page' . $disable_last, |
|
| 793 | - esc_attr__( 'Go to the next page' ), |
|
| 794 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
| 792 | + 'next-page'.$disable_last, |
|
| 793 | + esc_attr__('Go to the next page'), |
|
| 794 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
| 795 | 795 | '›' |
| 796 | 796 | ); |
| 797 | 797 | |
| 798 | 798 | $page_links[] = sprintf( |
| 799 | 799 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 800 | - 'last-page' . $disable_last, |
|
| 801 | - esc_attr__( 'Go to the last page' ), |
|
| 802 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
| 800 | + 'last-page'.$disable_last, |
|
| 801 | + esc_attr__('Go to the last page'), |
|
| 802 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
| 803 | 803 | '»' |
| 804 | 804 | ); |
| 805 | 805 | |
| 806 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
| 806 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
| 807 | 807 | // set page class |
| 808 | - if ( $total_pages ) { |
|
| 808 | + if ($total_pages) { |
|
| 809 | 809 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 810 | 810 | } else { |
| 811 | 811 | $page_class = ' no-pages'; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
| 814 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | * @param WP $WP |
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | - public function run( WP $WP ) { |
|
| 55 | - if ( did_action( 'pre_get_posts' ) && did_action( 'send_headers' ) ) { |
|
| 54 | + public function run(WP $WP) { |
|
| 55 | + if (did_action('pre_get_posts') && did_action('send_headers')) { |
|
| 56 | 56 | global $wp_query; |
| 57 | 57 | EED_Single_Page_Checkout::load_reg_steps(); |
| 58 | - EED_Single_Page_Checkout::init( $wp_query ); |
|
| 58 | + EED_Single_Page_Checkout::init($wp_query); |
|
| 59 | 59 | } else { |
| 60 | 60 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
| 61 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
| 61 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
| 62 | 62 | // this will trigger the EED_Single_Page_Checkout module's run() method during the pre_get_posts hook point, |
| 63 | 63 | // this allows us to initialize things, enqueue assets, etc, |
| 64 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'init' ), 10, 1 ); |
|
| 64 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'init'), 10, 1); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param array $attributes |
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | - public function process_shortcode( $attributes = array() ) { |
|
| 77 | + public function process_shortcode($attributes = array()) { |
|
| 78 | 78 | return EE_Registry::instance()->REQ->get_output(); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @access public |
| 51 | 51 | * @param \WP $WP |
| 52 | 52 | */ |
| 53 | - public function run( WP $WP ) { |
|
| 53 | + public function run(WP $WP) { |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | * @param array $attributes |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function process_shortcode( $attributes = array() ) { |
|
| 64 | - extract( $attributes ); |
|
| 65 | - $event_id = isset( $event_id ) ? $event_id : 0; |
|
| 66 | - $event = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $event_id ); |
|
| 63 | + public function process_shortcode($attributes = array()) { |
|
| 64 | + extract($attributes); |
|
| 65 | + $event_id = isset($event_id) ? $event_id : 0; |
|
| 66 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
| 67 | 67 | ob_start(); |
| 68 | - do_action( 'AHEE_event_details_before_post', $event_id ); |
|
| 69 | - espresso_ticket_selector( $event ); |
|
| 70 | - do_action( 'AHEE_event_details_after_post' ); |
|
| 68 | + do_action('AHEE_event_details_before_post', $event_id); |
|
| 69 | + espresso_ticket_selector($event); |
|
| 70 | + do_action('AHEE_event_details_after_post'); |
|
| 71 | 71 | return ob_get_clean(); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | * @param WP $WP |
| 51 | 51 | * @return void |
| 52 | 52 | */ |
| 53 | - public function run( WP $WP ) { |
|
| 54 | - if ( did_action( 'pre_get_posts' ) && did_action( 'send_headers' ) ) { |
|
| 53 | + public function run(WP $WP) { |
|
| 54 | + if (did_action('pre_get_posts') && did_action('send_headers')) { |
|
| 55 | 55 | EED_Events_Archive::instance()->event_list(); |
| 56 | 56 | } else { |
| 57 | 57 | // this will trigger the EED_Events_Archive module's event_list() method during the pre_get_posts hook point, |
| 58 | 58 | // this allows us to initialize things, enqueue assets, etc, |
| 59 | 59 | // as well, this saves an instantiation of the module in an array using 'espresso_events' as the key, so that we can retrieve it |
| 60 | - add_action( 'pre_get_posts', array( EED_Events_Archive::instance(), 'event_list' ) ); |
|
| 60 | + add_action('pre_get_posts', array(EED_Events_Archive::instance(), 'event_list')); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | * @param array $attributes |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public function process_shortcode( $attributes = array() ) { |
|
| 82 | + public function process_shortcode($attributes = array()) { |
|
| 83 | 83 | // make sure EED_Events_Archive is setup properly |
| 84 | - if ( apply_filters( 'FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE )) { |
|
| 84 | + if (apply_filters('FHEE__fallback_shortcode_processor__EES_Espresso_Events', FALSE)) { |
|
| 85 | 85 | EED_Events_Archive::instance()->event_list(); |
| 86 | 86 | } |
| 87 | 87 | // merge in any attributes passed via fallback shortcode processor |
| 88 | - $attributes = array_merge( (array)$attributes, (array)$this->_attributes ); |
|
| 88 | + $attributes = array_merge((array) $attributes, (array) $this->_attributes); |
|
| 89 | 89 | //set default attributes |
| 90 | 90 | $default_espresso_events_shortcode_atts = array( |
| 91 | 91 | 'title' => NULL, |
@@ -99,26 +99,26 @@ discard block |
||
| 99 | 99 | 'fallback_shortcode_processor' => FALSE |
| 100 | 100 | ); |
| 101 | 101 | // allow the defaults to be filtered |
| 102 | - $default_espresso_events_shortcode_atts = apply_filters( 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', $default_espresso_events_shortcode_atts ); |
|
| 102 | + $default_espresso_events_shortcode_atts = apply_filters('EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', $default_espresso_events_shortcode_atts); |
|
| 103 | 103 | // grab attributes and merge with defaults, then extract |
| 104 | - $attributes = array_merge( $default_espresso_events_shortcode_atts, $attributes ); |
|
| 104 | + $attributes = array_merge($default_espresso_events_shortcode_atts, $attributes); |
|
| 105 | 105 | // make sure we use the_excerpt() |
| 106 | - add_filter( 'FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true' ); |
|
| 106 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
| 107 | 107 | // apply query filters |
| 108 | - add_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' ); |
|
| 108 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
| 109 | 109 | // run the query |
| 110 | 110 | global $wp_query; |
| 111 | - $wp_query = new EE_Event_List_Query( $attributes ); |
|
| 111 | + $wp_query = new EE_Event_List_Query($attributes); |
|
| 112 | 112 | // check what template is loaded and load filters accordingly |
| 113 | - EED_Events_Archive::instance()->template_include( 'loop-espresso_events.php' ); |
|
| 113 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
| 114 | 114 | // load our template |
| 115 | - $event_list = EEH_Template::locate_template( 'loop-espresso_events.php', array(), TRUE, TRUE ); |
|
| 115 | + $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), TRUE, TRUE); |
|
| 116 | 116 | // now reset the query and postdata |
| 117 | 117 | wp_reset_query(); |
| 118 | 118 | wp_reset_postdata(); |
| 119 | 119 | EED_Events_Archive::remove_all_events_archive_filters(); |
| 120 | 120 | // remove query filters |
| 121 | - remove_filter( 'FHEE__EEH_Event_Query__apply_query_filters', '__return_true' ); |
|
| 121 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
| 122 | 122 | // pull our content from the output buffer and return it |
| 123 | 123 | return $event_list; |
| 124 | 124 | } |
@@ -163,46 +163,46 @@ discard block |
||
| 163 | 163 | * @param array $args |
| 164 | 164 | * @return \EE_Event_List_Query |
| 165 | 165 | */ |
| 166 | - function __construct( $args = array() ) { |
|
| 166 | + function __construct($args = array()) { |
|
| 167 | 167 | // EEH_Debug_Tools::printr( $args, '$args <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 168 | 168 | // incoming args could be a mix of WP query args + EE shortcode args |
| 169 | - foreach ( $args as $key =>$value ) { |
|
| 170 | - $property = '_' . $key; |
|
| 169 | + foreach ($args as $key =>$value) { |
|
| 170 | + $property = '_'.$key; |
|
| 171 | 171 | // if the arg is a property of this class, then it's an EE shortcode arg |
| 172 | - if ( property_exists( $this, $property )) { |
|
| 172 | + if (property_exists($this, $property)) { |
|
| 173 | 173 | // set the property value |
| 174 | 174 | $this->$property = $value; |
| 175 | 175 | // then remove it from the array of args that will later be passed to WP_Query() |
| 176 | - unset( $args[ $key ] ); |
|
| 176 | + unset($args[$key]); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | // setup the events list query |
| 180 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
| 180 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
| 181 | 181 | //add query filters |
| 182 | 182 | EEH_Event_Query::add_query_filters(); |
| 183 | 183 | // set params that will get used by the filters |
| 184 | - EEH_Event_Query::set_query_params( $this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort ); |
|
| 184 | + EEH_Event_Query::set_query_params($this->_month, $this->_category_slug, $this->_show_expired, $this->_order_by, $this->_sort); |
|
| 185 | 185 | // first off, let's remove any filters from previous queries |
| 186 | - remove_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' )); |
|
| 187 | - remove_all_filters( 'FHEE__content_espresso_events__event_class' ); |
|
| 186 | + remove_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title')); |
|
| 187 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
| 188 | 188 | // Event List Title ? |
| 189 | - add_filter( 'FHEE__archive_espresso_events_template__upcoming_events_h1', array( $this, 'event_list_title' ), 10, 1 ); |
|
| 189 | + add_filter('FHEE__archive_espresso_events_template__upcoming_events_h1', array($this, 'event_list_title'), 10, 1); |
|
| 190 | 190 | // add the css class |
| 191 | - add_filter( 'FHEE__content_espresso_events__event_class', array( $this, 'event_list_css' ), 10, 1 ); |
|
| 191 | + add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1); |
|
| 192 | 192 | // the current "page" we are viewing |
| 193 | - $paged = max( 1, get_query_var( 'paged' )); |
|
| 193 | + $paged = max(1, get_query_var('paged')); |
|
| 194 | 194 | // Force these args |
| 195 | - $args = array_merge( $args, array( |
|
| 195 | + $args = array_merge($args, array( |
|
| 196 | 196 | 'post_type' => 'espresso_events', |
| 197 | 197 | 'posts_per_page' => $this->_limit, |
| 198 | 198 | 'update_post_term_cache' => FALSE, |
| 199 | 199 | 'update_post_meta_cache' => FALSE, |
| 200 | 200 | 'paged' => $paged, |
| 201 | - 'offset' => ( $paged - 1 ) * $this->_limit |
|
| 201 | + 'offset' => ($paged - 1) * $this->_limit |
|
| 202 | 202 | )); |
| 203 | 203 | |
| 204 | 204 | // run the query |
| 205 | - parent::__construct( $args ); |
|
| 205 | + parent::__construct($args); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | * @param string $event_list_title |
| 216 | 216 | * @return string |
| 217 | 217 | */ |
| 218 | - public function event_list_title( $event_list_title = '' ) { |
|
| 219 | - if ( ! empty( $this->_title )) { |
|
| 218 | + public function event_list_title($event_list_title = '') { |
|
| 219 | + if ( ! empty($this->_title)) { |
|
| 220 | 220 | return $this->_title; |
| 221 | 221 | } |
| 222 | 222 | return $event_list_title; |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | * @param string $event_list_css |
| 232 | 232 | * @return array |
| 233 | 233 | */ |
| 234 | - public function event_list_css( $event_list_css = '' ) { |
|
| 235 | - $event_list_css .= ! empty( $event_list_css ) ? ' ' : ''; |
|
| 236 | - $event_list_css .= ! empty( $this->_css_class ) ? $this->_css_class : ''; |
|
| 237 | - $event_list_css .= ! empty( $event_list_css ) ? ' ' : ''; |
|
| 238 | - $event_list_css .= ! empty( $this->_category_slug ) ? $this->_category_slug : ''; |
|
| 234 | + public function event_list_css($event_list_css = '') { |
|
| 235 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
| 236 | + $event_list_css .= ! empty($this->_css_class) ? $this->_css_class : ''; |
|
| 237 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
| 238 | + $event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : ''; |
|
| 239 | 239 | return $event_list_css; |
| 240 | 240 | } |
| 241 | 241 | |