@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
| 18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * espresso_get_template_part |
| 21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | * @param string $name The name of the specialised template. |
| 26 | 26 | * @return string the html output for the formatted money value |
| 27 | 27 | */ |
| 28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
| 29 | - EEH_Template::get_template_part( $slug, $name ); |
|
| 28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
| 29 | + EEH_Template::get_template_part($slug, $name); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
| 35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
| 36 | 36 | /** |
| 37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
| 38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param string $suffix added to the end of the generated class |
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
| 45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @return boolean |
| 71 | 71 | */ |
| 72 | 72 | public static function is_espresso_theme() { |
| 73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
| 73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | 81 | public static function load_espresso_theme_functions() { |
| 82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
| 83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
| 84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
| 82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
| 83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
| 84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
| 93 | 93 | * @return array |
| 94 | 94 | */ |
| 95 | 95 | public static function get_espresso_themes() { |
| 96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
| 97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
| 98 | - if ( empty( $espresso_themes ) ) { |
|
| 96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
| 97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
| 98 | + if (empty($espresso_themes)) { |
|
| 99 | 99 | return array(); |
| 100 | 100 | } |
| 101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
| 102 | - unset( $espresso_themes[ $key ] ); |
|
| 101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
| 102 | + unset($espresso_themes[$key]); |
|
| 103 | 103 | } |
| 104 | 104 | EEH_Template::$_espresso_themes = array(); |
| 105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
| 106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
| 105 | + foreach ($espresso_themes as $espresso_theme) { |
|
| 106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @param bool $return_string |
| 123 | 123 | * @return string the html output for the formatted money value |
| 124 | 124 | */ |
| 125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
| 126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
| 125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
| 126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
| 127 | 127 | $templates = array(); |
| 128 | 128 | $name = (string) $name; |
| 129 | - if ( $name != '' ) { |
|
| 129 | + if ($name != '') { |
|
| 130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
| 131 | 131 | } |
| 132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
| 133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
| 134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
| 133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
| 134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -182,26 +182,26 @@ discard block |
||
| 182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
| 183 | 183 | * @return mixed |
| 184 | 184 | */ |
| 185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
| 185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
| 186 | 186 | // first use WP locate_template to check for template in the current theme folder |
| 187 | - $template_path = locate_template( $templates ); |
|
| 187 | + $template_path = locate_template($templates); |
|
| 188 | 188 | |
| 189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
| 189 | + if ($check_if_custom && ! empty($template_path)) |
|
| 190 | 190 | return TRUE; |
| 191 | 191 | |
| 192 | 192 | // not in the theme |
| 193 | - if ( empty( $template_path )) { |
|
| 193 | + if (empty($template_path)) { |
|
| 194 | 194 | // not even a template to look for ? |
| 195 | - if ( empty( $templates )) { |
|
| 195 | + if (empty($templates)) { |
|
| 196 | 196 | // get post_type |
| 197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
| 197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
| 198 | 198 | // get array of EE Custom Post Types |
| 199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
| 200 | 200 | // build template name based on request |
| 201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
| 202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
| 201 | + if (isset($EE_CPTs[$post_type])) { |
|
| 202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | // currently active EE template theme |
@@ -210,81 +210,81 @@ discard block |
||
| 210 | 210 | // array of paths to folders that may contain templates |
| 211 | 211 | $template_folder_paths = array( |
| 212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
| 213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
| 213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
| 214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
| 215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
| 219 | - if ( ! $check_if_custom ) { |
|
| 219 | + if ( ! $check_if_custom) { |
|
| 220 | 220 | $core_paths = array( |
| 221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
| 222 | - EE_PUBLIC . $current_theme, |
|
| 222 | + EE_PUBLIC.$current_theme, |
|
| 223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
| 224 | - EE_TEMPLATES . $current_theme, |
|
| 224 | + EE_TEMPLATES.$current_theme, |
|
| 225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
| 226 | 226 | EE_PLUGIN_DIR_PATH |
| 227 | 227 | ); |
| 228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
| 228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // now filter that array |
| 232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
| 233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
| 234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
| 232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
| 233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
| 234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
| 235 | 235 | // array to hold all possible template paths |
| 236 | 236 | $full_template_paths = array(); |
| 237 | 237 | |
| 238 | 238 | // loop through $templates |
| 239 | - foreach ( $templates as $template ) { |
|
| 239 | + foreach ($templates as $template) { |
|
| 240 | 240 | // normalize directory separators |
| 241 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
| 242 | - $file_name = basename( $template ); |
|
| 243 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
| 241 | + $template = EEH_File::standardise_directory_separators($template); |
|
| 242 | + $file_name = basename($template); |
|
| 243 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
| 244 | 244 | // while looping through all template folder paths |
| 245 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
| 245 | + foreach ($template_folder_paths as $template_folder_path) { |
|
| 246 | 246 | // normalize directory separators |
| 247 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
| 247 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
| 248 | 248 | // determine if any common base path exists between the two paths |
| 249 | 249 | $common_base_path = EEH_Template::_find_common_base_path( |
| 250 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
| 250 | + array($template_folder_path, $template_path_minus_file_name) |
|
| 251 | 251 | ); |
| 252 | - if ( $common_base_path !== '' ) { |
|
| 252 | + if ($common_base_path !== '') { |
|
| 253 | 253 | // both paths have a common base, so just tack the filename onto our search path |
| 254 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
| 254 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
| 255 | 255 | } else { |
| 256 | 256 | // no common base path, so let's just concatenate |
| 257 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
| 257 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
| 258 | 258 | } |
| 259 | 259 | // build up our template locations array by adding our resolved paths |
| 260 | 260 | $full_template_paths[] = $resolved_path; |
| 261 | 261 | } |
| 262 | 262 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
| 263 | - array_unshift( $full_template_paths, $template ); |
|
| 263 | + array_unshift($full_template_paths, $template); |
|
| 264 | 264 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
| 265 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
| 265 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
| 266 | 266 | } |
| 267 | 267 | // filter final array of full template paths |
| 268 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
| 268 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
| 269 | 269 | // now loop through our final array of template location paths and check each location |
| 270 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
| 271 | - if ( is_readable( $full_template_path )) { |
|
| 272 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
| 270 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
| 271 | + if (is_readable($full_template_path)) { |
|
| 272 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
| 273 | 273 | // hook that can be used to display the full template path that will be used |
| 274 | - do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path ); |
|
| 274 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
| 275 | 275 | break; |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | // if we got it and you want to see it... |
| 280 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
| 281 | - if ( $return_string ) { |
|
| 282 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 280 | + if ($template_path && $load && ! $check_if_custom) { |
|
| 281 | + if ($return_string) { |
|
| 282 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 283 | 283 | } else { |
| 284 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
| 284 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
| 287 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | |
@@ -297,21 +297,21 @@ discard block |
||
| 297 | 297 | * @param array $paths |
| 298 | 298 | * @return string |
| 299 | 299 | */ |
| 300 | - protected static function _find_common_base_path( $paths ) { |
|
| 300 | + protected static function _find_common_base_path($paths) { |
|
| 301 | 301 | $last_offset = 0; |
| 302 | 302 | $common_base_path = ''; |
| 303 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
| 303 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
| 304 | 304 | $dir_length = $index - $last_offset + 1; |
| 305 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
| 306 | - foreach ( $paths as $path ) { |
|
| 307 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
| 305 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
| 306 | + foreach ($paths as $path) { |
|
| 307 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
| 308 | 308 | return $common_base_path; |
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | $common_base_path .= $directory; |
| 312 | 312 | $last_offset = $index + 1; |
| 313 | 313 | } |
| 314 | - return substr( $common_base_path, 0, -1 ); |
|
| 314 | + return substr($common_base_path, 0, -1); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
| 324 | 324 | * @return mixed string |
| 325 | 325 | */ |
| 326 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
| 326 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -334,26 +334,26 @@ discard block |
||
| 334 | 334 | * |
| 335 | 335 | * @since 4.6.0 |
| 336 | 336 | */ |
| 337 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
| 338 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
| 337 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
| 338 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
| 339 | 339 | |
| 340 | 340 | // you gimme nuttin - YOU GET NUTTIN !! |
| 341 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
| 341 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
| 342 | 342 | return ''; |
| 343 | 343 | } |
| 344 | 344 | // if $template_args are not in an array, then make it so |
| 345 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
| 346 | - $template_args = array( $template_args ); |
|
| 345 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
| 346 | + $template_args = array($template_args); |
|
| 347 | 347 | } |
| 348 | - extract( (array) $template_args); |
|
| 348 | + extract((array) $template_args); |
|
| 349 | 349 | |
| 350 | - if ( $return_string ) { |
|
| 350 | + if ($return_string) { |
|
| 351 | 351 | // because we want to return a string, we are going to capture the output |
| 352 | 352 | ob_start(); |
| 353 | - include( $template_path ); |
|
| 353 | + include($template_path); |
|
| 354 | 354 | return ob_get_clean(); |
| 355 | 355 | } else { |
| 356 | - include( $template_path ); |
|
| 356 | + include($template_path); |
|
| 357 | 357 | } |
| 358 | 358 | return ''; |
| 359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
| 371 | 371 | * @param string $suffix added to the end of the generated class |
| 372 | 372 | * @return string |
| 373 | 373 | */ |
| 374 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 374 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 375 | 375 | // in the beginning... |
| 376 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
| 376 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
| 377 | 377 | // da muddle |
| 378 | 378 | $class = ''; |
| 379 | 379 | // the end |
| 380 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
| 380 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
| 381 | 381 | // is the passed object an EE object ? |
| 382 | - if ( $object instanceof EE_Base_Class ) { |
|
| 382 | + if ($object instanceof EE_Base_Class) { |
|
| 383 | 383 | // grab the exact type of object |
| 384 | - $obj_class = get_class( $object ); |
|
| 384 | + $obj_class = get_class($object); |
|
| 385 | 385 | // depending on the type of object... |
| 386 | - switch ( $obj_class ) { |
|
| 386 | + switch ($obj_class) { |
|
| 387 | 387 | // no specifics just yet... |
| 388 | 388 | default : |
| 389 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
| 390 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
| 389 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
| 390 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | - return $prefix . $class . $suffix; |
|
| 394 | + return $prefix.$class.$suffix; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | |
@@ -407,54 +407,54 @@ discard block |
||
| 407 | 407 | * @param string $cur_code_span_class |
| 408 | 408 | * @return string the html output for the formatted money value |
| 409 | 409 | */ |
| 410 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
| 410 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
| 411 | 411 | // ensure amount was received |
| 412 | - if ( is_null( $amount ) ) { |
|
| 413 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
| 414 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 412 | + if (is_null($amount)) { |
|
| 413 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
| 414 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 415 | 415 | return ''; |
| 416 | 416 | } |
| 417 | 417 | //ensure amount is float |
| 418 | - $amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount ); |
|
| 419 | - $CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount ); |
|
| 418 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
| 419 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
| 420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
| 421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
| 421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
| 422 | 422 | // still a number or was amount converted to a string like "free" ? |
| 423 | - if ( is_float( $amount_formatted )) { |
|
| 423 | + if (is_float($amount_formatted)) { |
|
| 424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
| 425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
| 425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
| 426 | 426 | // verify results |
| 427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
| 427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
| 428 | 428 | // set default config country currency settings |
| 429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
| 430 | 430 | } |
| 431 | 431 | // format float |
| 432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
| 432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
| 433 | 433 | // add formatting ? |
| 434 | - if ( ! $return_raw ) { |
|
| 434 | + if ( ! $return_raw) { |
|
| 435 | 435 | // add currency sign |
| 436 | - if( $mny->sign_b4 ){ |
|
| 437 | - if( $amount >= 0 ){ |
|
| 438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
| 439 | - }else{ |
|
| 440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
| 436 | + if ($mny->sign_b4) { |
|
| 437 | + if ($amount >= 0) { |
|
| 438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
| 439 | + } else { |
|
| 440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - }else{ |
|
| 444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
| 443 | + } else { |
|
| 444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | // filter to allow global setting of display_code |
| 448 | - $display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code ); |
|
| 448 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
| 449 | 449 | |
| 450 | 450 | // add currency code ? |
| 451 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
| 451 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
| 452 | 452 | } |
| 453 | 453 | // filter results |
| 454 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
| 454 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
| 455 | 455 | } |
| 456 | 456 | // clean up vars |
| 457 | - unset( $mny ); |
|
| 457 | + unset($mny); |
|
| 458 | 458 | // return formatted currency amount |
| 459 | 459 | return $amount_formatted; |
| 460 | 460 | } |
@@ -469,11 +469,11 @@ discard block |
||
| 469 | 469 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
| 470 | 470 | * @return string The localized label for the status id. |
| 471 | 471 | */ |
| 472 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
| 472 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
| 473 | 473 | /** @type EEM_Status $EEM_Status */ |
| 474 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
| 475 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
| 476 | - return $status[ $status_id ]; |
|
| 474 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
| 475 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
| 476 | + return $status[$status_id]; |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | |
@@ -488,21 +488,21 @@ discard block |
||
| 488 | 488 | * @param string $title |
| 489 | 489 | * @return string the html output for the button |
| 490 | 490 | */ |
| 491 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '', $title = '' ) { |
|
| 491 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') { |
|
| 492 | 492 | $icon_html = ''; |
| 493 | - if ( ! empty( $icon ) ) { |
|
| 494 | - $dashicons = preg_split( "(ee-icon |dashicons )", $icon ); |
|
| 495 | - $dashicons = array_filter( $dashicons ); |
|
| 496 | - $count = count( $dashicons ); |
|
| 493 | + if ( ! empty($icon)) { |
|
| 494 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
| 495 | + $dashicons = array_filter($dashicons); |
|
| 496 | + $count = count($dashicons); |
|
| 497 | 497 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
| 498 | - foreach ( $dashicons as $dashicon ) { |
|
| 499 | - $type = strpos( $dashicon, 'ee-icon' ) !== false ? 'ee-icon ' : 'dashicons '; |
|
| 500 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
| 498 | + foreach ($dashicons as $dashicon) { |
|
| 499 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
| 500 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
| 501 | 501 | } |
| 502 | 502 | $icon_html .= $count > 1 ? '</span>' : ''; |
| 503 | 503 | } |
| 504 | - $label = ! empty( $icon ) ? $icon_html . $label : $label; |
|
| 505 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
| 504 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
| 505 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
| 506 | 506 | return $button; |
| 507 | 507 | } |
| 508 | 508 | |
@@ -519,21 +519,21 @@ discard block |
||
| 519 | 519 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
| 520 | 520 | * @return string generated link |
| 521 | 521 | */ |
| 522 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
| 522 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
| 523 | 523 | |
| 524 | - if ( ! $page ) |
|
| 525 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 524 | + if ( ! $page) |
|
| 525 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
| 526 | 526 | |
| 527 | - if ( ! $action ) |
|
| 528 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 527 | + if ( ! $action) |
|
| 528 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
| 529 | 529 | |
| 530 | 530 | $action = empty($action) ? 'default' : $action; |
| 531 | 531 | |
| 532 | 532 | |
| 533 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
| 534 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 535 | - $help_text = !$help_text ? '' : $help_text; |
|
| 536 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
| 533 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
| 534 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 535 | + $help_text = ! $help_text ? '' : $help_text; |
|
| 536 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | |
@@ -545,31 +545,31 @@ discard block |
||
| 545 | 545 | * @param EE_Help_Tour |
| 546 | 546 | * @return string html |
| 547 | 547 | */ |
| 548 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
| 548 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
| 549 | 549 | $id = $tour->get_slug(); |
| 550 | 550 | $stops = $tour->get_stops(); |
| 551 | 551 | |
| 552 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
| 552 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
| 553 | 553 | |
| 554 | - foreach ( $stops as $stop ) { |
|
| 555 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
| 556 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
| 554 | + foreach ($stops as $stop) { |
|
| 555 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
| 556 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
| 557 | 557 | |
| 558 | 558 | //if container is set to modal then let's make sure we set the options accordingly |
| 559 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
| 559 | + if (empty($data_id) && empty($data_class)) { |
|
| 560 | 560 | $stop['options']['modal'] = true; |
| 561 | 561 | $stop['options']['expose'] = true; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
| 565 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
| 564 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
| 565 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
| 566 | 566 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
| 567 | 567 | |
| 568 | 568 | //options |
| 569 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
| 569 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
| 570 | 570 | $options = ' data-options="'; |
| 571 | - foreach ( $stop['options'] as $option => $value ) { |
|
| 572 | - $options .= $option . ':' . $value . ';'; |
|
| 571 | + foreach ($stop['options'] as $option => $value) { |
|
| 572 | + $options .= $option.':'.$value.';'; |
|
| 573 | 573 | } |
| 574 | 574 | $options .= '"'; |
| 575 | 575 | } else { |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | //let's put all together |
| 580 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
| 580 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | $content .= '</ol>'; |
@@ -598,31 +598,31 @@ discard block |
||
| 598 | 598 | * @throws EE_Error |
| 599 | 599 | * @return string html structure for status. |
| 600 | 600 | */ |
| 601 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
| 602 | - if ( !is_array( $status_array ) ) |
|
| 603 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 601 | + public static function status_legend($status_array, $active_status = '') { |
|
| 602 | + if ( ! is_array($status_array)) |
|
| 603 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
| 604 | 604 | |
| 605 | 605 | $setup_array = array(); |
| 606 | - foreach ( $status_array as $item => $status ) { |
|
| 606 | + foreach ($status_array as $item => $status) { |
|
| 607 | 607 | $setup_array[$item] = array( |
| 608 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
| 609 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
| 608 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
| 609 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
| 610 | 610 | 'status' => $status |
| 611 | 611 | ); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
| 615 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
| 616 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
| 617 | - foreach ( $setup_array as $item => $details ) { |
|
| 614 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
| 615 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
| 616 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
| 617 | + foreach ($setup_array as $item => $details) { |
|
| 618 | 618 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
| 619 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
| 620 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
| 621 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
| 622 | - $content .= '</dt>' . "\n"; |
|
| 619 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
| 620 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
| 621 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
| 622 | + $content .= '</dt>'."\n"; |
|
| 623 | 623 | } |
| 624 | - $content .= '</dl>' . "\n"; |
|
| 625 | - $content .= '</div>' . "\n"; |
|
| 624 | + $content .= '</dl>'."\n"; |
|
| 625 | + $content .= '</div>'."\n"; |
|
| 626 | 626 | return $content; |
| 627 | 627 | } |
| 628 | 628 | |
@@ -635,8 +635,8 @@ discard block |
||
| 635 | 635 | * @return string |
| 636 | 636 | */ |
| 637 | 637 | public static function layout_array_as_table($data) { |
| 638 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
| 639 | - $data = (array)$data; |
|
| 638 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 639 | + $data = (array) $data; |
|
| 640 | 640 | } |
| 641 | 641 | ob_start(); |
| 642 | 642 | if (is_array($data)) { |
@@ -649,10 +649,10 @@ discard block |
||
| 649 | 649 | ?> |
| 650 | 650 | <tr> |
| 651 | 651 | <td> |
| 652 | - <?php echo $data_key;?> |
|
| 652 | + <?php echo $data_key; ?> |
|
| 653 | 653 | </td> |
| 654 | 654 | <td> |
| 655 | - <?php echo self::layout_array_as_table($data_values);?> |
|
| 655 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
| 656 | 656 | </td> |
| 657 | 657 | </tr> |
| 658 | 658 | <?php |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | <ul> |
| 667 | 667 | <?php |
| 668 | 668 | foreach ($data as $datum) { |
| 669 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
| 669 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
| 670 | 670 | }?> |
| 671 | 671 | </ul> |
| 672 | 672 | <?php |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | * |
| 697 | 697 | * @return string |
| 698 | 698 | */ |
| 699 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 700 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
| 699 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 700 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
@@ -721,13 +721,13 @@ discard block |
||
| 721 | 721 | * ) |
| 722 | 722 | * @return string |
| 723 | 723 | */ |
| 724 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 724 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 725 | 725 | $page_links = array(); |
| 726 | 726 | $disable_first = $disable_last = ''; |
| 727 | 727 | $total_items = (int) $total_items; |
| 728 | 728 | $per_page = (int) $per_page; |
| 729 | 729 | $current = (int) $current; |
| 730 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
| 730 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
| 731 | 731 | |
| 732 | 732 | //filter items_label |
| 733 | 733 | $items_label = apply_filters( |
@@ -735,68 +735,68 @@ discard block |
||
| 735 | 735 | $items_label |
| 736 | 736 | ); |
| 737 | 737 | |
| 738 | - if ( empty( $items_label ) |
|
| 739 | - || ! is_array( $items_label ) |
|
| 740 | - || ! isset( $items_label['single'] ) |
|
| 741 | - || ! isset( $items_label['plural'] ) ) { |
|
| 738 | + if (empty($items_label) |
|
| 739 | + || ! is_array($items_label) |
|
| 740 | + || ! isset($items_label['single']) |
|
| 741 | + || ! isset($items_label['plural'])) { |
|
| 742 | 742 | $items_label = array( |
| 743 | - 'single' => __( '1 item', 'event_espresso' ), |
|
| 744 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
| 743 | + 'single' => __('1 item', 'event_espresso'), |
|
| 744 | + 'plural' => __('%s items', 'event_espresso') |
|
| 745 | 745 | ); |
| 746 | 746 | } else { |
| 747 | 747 | $items_label = array( |
| 748 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
| 749 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
| 748 | + 'single' => '1 '.esc_html($items_label['single']), |
|
| 749 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
| 750 | 750 | ); |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 753 | + $total_pages = ceil($total_items / $per_page); |
|
| 754 | 754 | |
| 755 | - if ( $total_pages <= 1 ) |
|
| 755 | + if ($total_pages <= 1) |
|
| 756 | 756 | return ''; |
| 757 | 757 | |
| 758 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
| 758 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
| 759 | 759 | |
| 760 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
| 760 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
| 761 | 761 | |
| 762 | - if ( $current === 1 ) { |
|
| 762 | + if ($current === 1) { |
|
| 763 | 763 | $disable_first = ' disabled'; |
| 764 | 764 | } |
| 765 | - if ( $current == $total_pages ) { |
|
| 765 | + if ($current == $total_pages) { |
|
| 766 | 766 | $disable_last = ' disabled'; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 770 | - 'first-page' . $disable_first, |
|
| 771 | - esc_attr__( 'Go to the first page' ), |
|
| 772 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
| 769 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 770 | + 'first-page'.$disable_first, |
|
| 771 | + esc_attr__('Go to the first page'), |
|
| 772 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
| 773 | 773 | '«' |
| 774 | 774 | ); |
| 775 | 775 | |
| 776 | 776 | $page_links[] = sprintf( |
| 777 | 777 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 778 | - 'prev-page' . $disable_first, |
|
| 779 | - esc_attr__( 'Go to the previous page' ), |
|
| 780 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
| 778 | + 'prev-page'.$disable_first, |
|
| 779 | + esc_attr__('Go to the previous page'), |
|
| 780 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
| 781 | 781 | '‹' |
| 782 | 782 | ); |
| 783 | 783 | |
| 784 | - if ( ! $show_num_field ) { |
|
| 784 | + if ( ! $show_num_field) { |
|
| 785 | 785 | $html_current_page = $current; |
| 786 | 786 | } else { |
| 787 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 788 | - esc_attr__( 'Current page' ), |
|
| 787 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 788 | + esc_attr__('Current page'), |
|
| 789 | 789 | $current, |
| 790 | - strlen( $total_pages ) |
|
| 790 | + strlen($total_pages) |
|
| 791 | 791 | ); |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | $html_total_pages = sprintf( |
| 795 | 795 | '<span class="total-pages">%s</span>', |
| 796 | - number_format_i18n( $total_pages ) |
|
| 796 | + number_format_i18n($total_pages) |
|
| 797 | 797 | ); |
| 798 | 798 | $page_links[] = sprintf( |
| 799 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
| 799 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
| 800 | 800 | $html_current_page, |
| 801 | 801 | $html_total_pages, |
| 802 | 802 | '<span class="paging-input">', |
@@ -805,29 +805,29 @@ discard block |
||
| 805 | 805 | |
| 806 | 806 | $page_links[] = sprintf( |
| 807 | 807 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 808 | - 'next-page' . $disable_last, |
|
| 809 | - esc_attr__( 'Go to the next page' ), |
|
| 810 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
| 808 | + 'next-page'.$disable_last, |
|
| 809 | + esc_attr__('Go to the next page'), |
|
| 810 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
| 811 | 811 | '›' |
| 812 | 812 | ); |
| 813 | 813 | |
| 814 | 814 | $page_links[] = sprintf( |
| 815 | 815 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 816 | - 'last-page' . $disable_last, |
|
| 817 | - esc_attr__( 'Go to the last page' ), |
|
| 818 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
| 816 | + 'last-page'.$disable_last, |
|
| 817 | + esc_attr__('Go to the last page'), |
|
| 818 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
| 819 | 819 | '»' |
| 820 | 820 | ); |
| 821 | 821 | |
| 822 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
| 822 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
| 823 | 823 | // set page class |
| 824 | - if ( $total_pages ) { |
|
| 824 | + if ($total_pages) { |
|
| 825 | 825 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 826 | 826 | } else { |
| 827 | 827 | $page_class = ' no-pages'; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
| 830 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | |
@@ -837,18 +837,18 @@ discard block |
||
| 837 | 837 | * @param string $wrap_id |
| 838 | 838 | * @return string |
| 839 | 839 | */ |
| 840 | - public static function powered_by_event_espresso( $wrap_class = '', $wrap_id = '' ) { |
|
| 841 | - $attributes = ! empty( $wrap_id ) ? " id=\"{$wrap_id}\"" : ''; |
|
| 842 | - $attributes .= ! empty( $wrap_class ) |
|
| 840 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '') { |
|
| 841 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
| 842 | + $attributes .= ! empty($wrap_class) |
|
| 843 | 843 | ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
| 844 | 844 | : ' class="powered-by-event-espresso-credit"'; |
| 845 | 845 | |
| 846 | 846 | $url = add_query_arg( |
| 847 | - array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id() ), |
|
| 847 | + array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id()), |
|
| 848 | 848 | 'https://eventespresso.com/' |
| 849 | 849 | ); |
| 850 | - $url = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso__url', $url ); |
|
| 851 | - $powered_by = is_admin() && ! ( defined('DOING_AJAX') && DOING_AJAX ) |
|
| 850 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
| 851 | + $powered_by = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
| 852 | 852 | ? EVENT_ESPRESSO_POWERED_BY |
| 853 | 853 | : 'Event Espresso'; |
| 854 | 854 | return (string) apply_filters( |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
| 881 | 881 | |
| 882 | 882 | |
| 883 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
| 883 | +if ( ! function_exists('espresso_pagination')) { |
|
| 884 | 884 | /** |
| 885 | 885 | * espresso_pagination |
| 886 | 886 | * |
@@ -892,21 +892,21 @@ discard block |
||
| 892 | 892 | $big = 999999999; // need an unlikely integer |
| 893 | 893 | $pagination = paginate_links( |
| 894 | 894 | array( |
| 895 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 895 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 896 | 896 | 'format' => '?paged=%#%', |
| 897 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 897 | + 'current' => max(1, get_query_var('paged')), |
|
| 898 | 898 | 'total' => $wp_query->max_num_pages, |
| 899 | 899 | 'show_all' => true, |
| 900 | 900 | 'end_size' => 10, |
| 901 | 901 | 'mid_size' => 6, |
| 902 | 902 | 'prev_next' => true, |
| 903 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
| 904 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
| 903 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
| 904 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
| 905 | 905 | 'type' => 'plain', |
| 906 | 906 | 'add_args' => false, |
| 907 | 907 | 'add_fragment' => '' |
| 908 | 908 | ) |
| 909 | 909 | ); |
| 910 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
| 910 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
| 911 | 911 | } |
| 912 | 912 | } |
| 913 | 913 | \ No newline at end of file |