f ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /* * Event Calendar generate (sets up variables and loads template) * * * @param string $template Which template to use * @param array $options Options * > 'date_format' Format to use when displaying date of event (eg: "D d.m.Y") * > 'limit' How many events to display * > 'category' Filter on this category */ function event_calendar_generate ($template, $options, $current_post_id = 0) { global $glz_countries; if (empty($template) or empty($options)) { exit; } // Get limit of events $limit = ( isset($options['limit']) and is_numeric($options['limit']) ) ? intval($options['limit']) : false; // Check if category is given $filter_category = ( ! empty($options['category']) ) ? $options['category'] : false; // Start outputting $template_part = 'top'; require($template); $count = 0; $xx = get_field('ec_events', 'options'); //fluo_debug_log(basename(__FILE__).':'.__LINE__.':'.__FUNCTION__.':ec_events:xx:', $xx); while ( have_rows('ec_events', 'options') ) { the_row(); // Check category if ( $filter_category ) { $matched_filter = false; $categories = get_sub_field('ec_category'); if ( ! empty($categories) and is_array($categories) ) { foreach( $categories as $idx => $category ) { if ( $category['value'] == $filter_category ) { $matched_filter = true; break; } } } if ( ! $matched_filter ) { continue; } } // Get event dates $date_tbc = get_sub_field('ec_date_tbc'); $date_postponed = get_sub_field('ec_date_postponed'); $start_date_ts = get_sub_field('ec_start_date'); $start_date_ts = mktime(0, 0, 0, substr($start_date_ts, 4, 2), substr($start_date_ts, 6, 2), substr($start_date_ts, 0, 4)); $start_date = date_i18n($options['date_format'], $start_date_ts); // If limit is set: only show upcoming events if ( $limit and $start_date_ts <= time() ) { continue; } // Check if we want to display a specific single event only (that is linked to the current page) if ( ! empty($current_post_id) ) { $linked_detail_page = get_sub_field('ec_linked_to_detail_page'); if ( empty($linked_detail_page) or $linked_detail_page != $current_post_id) { continue; } } $count++; $index = $count; // synonym // Check if we reached the limit if any is set if ( $limit and $count > $limit ) { break; } if($date_tbc){ $date = "TBC"; } elseif($date_postponed){ $date = "Postponed"; } else{ $day = date_i18n('l', $start_date_ts); $date = "{$day} {$start_date}"; $end_date_ts = get_sub_field('ec_end_date'); if ( $end_date_ts ) { $end_date_ts = mktime(0, 0, 0, substr($end_date_ts, 4, 2), substr($end_date_ts, 6, 2), substr($end_date_ts, 0, 4)); $end_date = date_i18n($options['date_format'], $end_date_ts); $date = "{$date} - {$end_date}"; } } $name = get_sub_field('ec_name'); $contact_email = get_sub_field('ec_contact_email'); $image = $logo = get_sub_field('ec_logo'); $country = strtolower(get_sub_field('ec_country')); if ( empty($country) ) { $country_flag = GLZ_EXT_URL . "/assets/images/countries/uci.png"; $country = ''; } else { $country_flag = GLZ_EXT_URL . "/assets/images/countries/{$country}.png"; } $country_alpha3_iso = strtoupper( isset($glz_countries[$country]['iso3']) ? $glz_countries[$country]['iso3'] : $country ); $country_alpha3 = strtoupper(glz_get_country_ioc3_from_iso3($country_alpha3_iso)); $country = strtoupper($country); $city = get_sub_field("ec_city"); if ( time() > $start_date_ts ) { $registrations_active = false; $registration_url = 'past'; } else { $registrations_active = get_sub_field('ec_registrations_active'); $registration_url = get_sub_field("ec_registration"); } $registration_url_is_internal = glz_is_internal($registration_url); $website_active = get_sub_field('ec_website_active'); $website_inactive_label = get_sub_field("ec_website_inactive_label"); $website_url = get_sub_field("ec_url"); $website_url_is_internal = glz_is_internal($website_url); $linked_detail_page = get_sub_field('ec_linked_to_detail_page'); $distances = array(); while ( have_rows('ec_distances', 'options') ) { the_row(); $distances[] = get_sub_field('ec_distance'); } $template_part = 'middle'; require($template); } $template_part = 'bottom'; require($template); } {"code":"rest_not_logged_in","message":"Vous n\u2019\u00eates actuellement pas connect\u00e9.","data":{"status":401}}