/wp-admin/plugins.php'; return; } if (!class_exists('acf') ) { echo 'ACF not activated. Make sure you activate the plugin in /wp-admin/plugins.php'; return; } $context = Timber::get_context(); if (is_front_page()) { $meta_query = ['relation' => 'OR', ['key' => 'performance_datetime', 'value' => date('Y-m-d H:i:s'), 'compare' => '>=', 'type' => 'DATETIME'], ['key' => 'performance_datetime', 'compare' => 'NOT EXISTS']]; $display = get_field('display', 'option'); if ($display === 'events') { $posts = Timber::get_posts(['numberposts' => -1, 'post_type' => ['event', 'festival', 'collections'], 'meta_query' => $meta_query, 'post__in' => get_field('events', 'option') ?: [0], 'orderby' => ['meta_value' => 'asc']]); $posts = empty($posts) ? Timber::get_posts(['numberposts' => 1, 'post_type' => ['event', 'festival', 'collections'], 'meta_key' => 'performance_datetime', 'meta_query' => $meta_query, 'orderby' => ['meta_value' => 'asc']]) : $posts; } if ($display === 'custom') { $item = (object) get_field('custom', 'option'); $item->thumbnail = new TimberImage($item->thumbnail); $posts = [$item]; } $meta_query = ['relation' => 'AND', ['key' => 'performance_datetime', 'value' => date('Y-m-d H:i:s'), 'compare' => '>=', 'type' => 'DATETIME'], ['key' => 'ticket_status', 'value' => ['C', 'S'], 'compare' => 'NOT IN'], ['relation' => 'OR', ['key' => 'program_hidden', 'value' => '0'], ['key' => 'program_hidden', 'compare' => 'NOT EXISTS']]]; $items = Timber::get_posts(['numberposts' => 4, 'post_type' => ['event', 'festival'], 'meta_key' => 'performance_datetime', 'meta_query' => $meta_query, 'orderby' => ['meta_value' => 'asc']]); $context['posts'] = $posts; $context['featured'] = get_field('featured', 'option'); $context['arrangements'] = get_field('arrangements', 'option'); $context['items'] = order_events_by_month($items); $template = ['home.twig']; } else if (is_page()) { $context['post'] = new Timber\Post(); $template = ['page-' . $context['post']->_wp_page_template . '.twig', 'page.twig']; } else if (is_tax(['artist', 'collection', 'filter'])) { $posts = new Timber\PostQuery(); $context['term'] = new Timber\Term(); $context['months'] = order_events_by_month($posts); $context['posts'] = $posts; $template = ['event-taxonomy.twig']; } else if (is_post_type_archive(['event', 'festival'])) { global $posts; $genres = Timber::get_terms('genre', ['parent' => 0, 'hide_empty' => true]); $subgenres = Timber::get_terms('genre', ['exclude' => wp_list_pluck($genres, 'id'), 'hide_empty' => true]); $context['filters'] = Timber::get_terms('filter', ['hide_empty' => true]); $context['locations'] = get_locations($posts); $context['months'] = order_events_by_month($posts); $context['subgenres'] = $subgenres; $context['genres'] = $genres; $template = ['event-archive.twig']; } else if (is_singular('event')) { $post = new Timber\Post(); $english = get_english_tips($post); $more = get_more_from_artist($post); $tips = get_event_tips($post); if (!is_event_in_future($post) && !empty($more) && !isset($_GET['preview'])) { $term = wp_get_post_terms($post->ID, 'artist')[0]; $url = count($more) > 1 ? get_term_link($term) : get_permalink($more[0]); wp_safe_redirect($url, 301); exit(); } if (has_term('summerstage', 'collection', $post->ID)) { $summerstage_event_id = get_post_meta($post->ID, 'summerstage_event', true); $url = get_permalink($summerstage_event_id); wp_safe_redirect($url, 301); exit(); } $arrangements = get_arrangements($post); $arrangements_nl = array_filter($arrangements, fn($post) => str_contains($post->post_name, 'english') === false); $arrangements_nl = array_values($arrangements_nl); $arrangements_en = array_filter($arrangements, fn($post) => str_contains($post->post_name, 'english') === true); $arrangements_en = array_values($arrangements_en); $context['future'] = is_event_in_future($post); $context['arrangements_nl'] = $context['future'] ? $arrangements_nl : false; $context['arrangements_en'] = $context['future'] ? $arrangements_en : false; $context['pricing'] = $context['future'] ? flatten_event_pricing($post) : false; $context['more'] = order_events_by_month($more); $context['english'] = $english; $context['post'] = $post; $context['tips'] = $tips; $template = ['event-single.twig']; } else if (is_singular('festival')) { $festival = new TimberPost(); $context['events'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_event', 'meta_query' => [['key' => 'festival', 'value' => $festival->id]], 'orderby' => ['menu_order' => 'asc']]); $context['pages'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_page', 'meta_query' => [['key' => 'festival', 'value' => $festival->id], ['key' => 'show_in_menu', 'value' => 1]], 'orderby' => ['menu_order' => 'asc']]); $context['archive'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_archive', 'meta_query' => [['key' => 'festival', 'value' => $festival->id]]]); $context['news'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_news', 'meta_query' => [['key' => 'festival', 'value' => $festival->id]]]); $context['future'] = is_event_in_future($festival); $context['pricing'] = $context['future'] ? flatten_event_pricing($festival) : false; $context['festival'] = $festival; if ($festival->theme === 'summerstage') { $event_ids = [0, ...array_map(fn($item) => $item->event, $context['events']) ]; $context['events'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'event', 'post__in' => $event_ids, 'orderby' => ['meta_value' => 'asc'], 'meta_key' => 'performance_datetime', 'meta_query' => [['key' => 'performance_datetime', 'value' => date('Y-m-d H:i:s'), 'compare' => '>=', 'type' => 'DATETIME']]]); } $template = [ 'festivals/' . $festival->theme . '/home.twig', 'festival-home.twig' ]; } else if (is_post_type_archive(['festival_event', 'festival_news', 'festival_archive'])) { global $wp_query; $posts = new Timber\PostQuery(); if (is_post_type_archive('festival_archive')) { $post_type = get_queried_object(); $page = Timber::get_post(['post_type' => 'festival_page', 'name' => basename($post_type->rewrite['slug']), 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['years'] = order_archive_by_years($posts); $context['page'] = $page; } if (is_post_type_archive('festival_event') && $wp_query->festival->theme === 'summerstage') { $url = get_permalink($wp_query->festival); wp_safe_redirect($url); exit(); } $context['events'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_event', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]], 'orderby' => ['menu_order' => 'asc']]); $context['pages'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_page', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id], ['key' => 'show_in_menu', 'value' => 1]], 'orderby' => ['menu_order' => 'asc']]); $context['archive'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_archive', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['news'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_news', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['future'] = is_event_in_future($wp_query->festival); $context['pricing'] = $context['future'] ? flatten_event_pricing($wp_query->festival) : false; $context['festival'] = $wp_query->festival; $context['posts'] = $posts; $template = [ 'festivals/' . $wp_query->festival->theme . '/' . str_replace('festival_', '', $wp_query->query['post_type']) . '-archive.twig', str_replace('_', '-', $wp_query->query['post_type']) . '-archive.twig' ]; } else if (is_singular(['festival_event', 'festival_news', 'festival_archive'])) { global $wp_query; $post = new Timber\Post(); if ($post->post_type === 'festival_archive' && !$post->has_detail) { $year = substr($post->archive_date, 0, 4); $url = get_post_type_archive_link('festival_archive'); $url .= '#jaar=' . $year; wp_safe_redirect($url, 301); exit(); } if ($post->post_type === 'festival_event' && $wp_query->festival->theme === 'summerstage') { $event_id = get_post_meta($post->ID, 'event', true); $post = Timber::get_post($event_id); $context['future'] = is_event_in_future($post); } $context['events'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_event', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]], 'orderby' => ['menu_order' => 'asc']]); $context['pages'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_page', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id], ['key' => 'show_in_menu', 'value' => 1]], 'orderby' => ['menu_order' => 'asc']]); $context['archive'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_archive', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['news'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_news', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['future'] = $context['future'] ?? is_event_in_future($wp_query->festival); $context['pricing'] = $context['future'] ? flatten_event_pricing($wp_query->festival) : false; $context['festival'] = $wp_query->festival; $context['post'] = $post; $template = [ 'festivals/' . $wp_query->festival->theme . '/' . str_replace('festival_', '', $wp_query->query['post_type']) . '-single.twig', str_replace('_', '-', $wp_query->query['post_type']) . '-single.twig' ]; } else if (is_singular('festival_page')) { global $wp_query; $post = new Timber\Post(); $context['events'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_event', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['pages'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_page', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id], ['key' => 'show_in_menu', 'value' => 1]], 'orderby' => ['menu_order' => 'asc']]); $context['archive'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_archive', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['news'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'festival_news', 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]]]); $context['future'] = is_event_in_future($wp_query->festival); $context['pricing'] = $context['future'] ? flatten_event_pricing($wp_query->festival) : false; $context['festival'] = $wp_query->festival; $context['post'] = $post; $template = [ 'festivals/' . $wp_query->festival->theme . '/page-' . $post->post_name . '.twig', 'festivals/' . $wp_query->festival->theme . '/page.twig', 'festival-page.twig' ]; if ($post->post_name === 'zoeken') { $context['results'] = !empty($_GET['q']) ? Timber::get_posts(['numberposts' => -1, 'post_type' => ['festival_event', 'festival_page', 'festival_news', 'festival_archive'], 'meta_query' => [['key' => 'festival', 'value' => $wp_query->festival->id]], 'order' => 'desc', 's' => $_GET['q']]) : false; $context['search'] = $_GET['q']; $template = 'festivals/' . $wp_query->festival->theme . '/search.twig'; } } else if (is_post_type_archive('arrangement')) { $post_type = get_queried_object(); $page = get_page_by_path($post_type->rewrite['slug']); $context['page'] = new TimberPost($page->ID); $context['posts'] = new Timber\PostQuery(); $template = ['arrangement-archive.twig']; } else if (is_singular('arrangement')) { $post = new TimberPost(); $context['performances'] = order_arrangements_by_month($post); $context['post'] = $post; $template = ['arrangement-single.twig']; } else if (is_post_type_archive('news')) { $context['posts'] = new Timber\PostQuery(); $template = ['news-archive.twig']; } else if (is_singular('news')) { $post = new TimberPost(); $context['news'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'news', 'post__not_in' => [$post->ID]]); $context['post'] = $post; $template = ['news-single.twig']; } else if (is_singular('narrowcasting')) { $post = new TimberPost(); $context['scheduled'] = has_scheduled_screens($post); $context['facilities'] = parse_facilities($post); $context['venue'] = parse_venue($post); $context['post'] = $post; $template = ['narrowcasting-' . $post->post_name . '.twig', 'narrowcasting.twig']; } else if (is_search()) { if (empty($_GET['s'])) { $url = home_url('/'); wp_safe_redirect($url, 301); exit(); } $context['posts'] = new Timber\PostQuery(); $template = ['search.twig']; } else if (is_404()) { $meta_query = [['key' => 'performance_datetime', 'value' => date('Y-m-d H:i:s'), 'compare' => '>=', 'type' => 'DATETIME']]; $context['posts'] = Timber::get_posts(['numberposts' => 3, 'post_type' => ['event', 'festival'], 'meta_key' => 'performance_datetime', 'meta_query' => $meta_query, 'orderby' => ['meta_value' => 'asc']]); $template = ['errors/404.twig']; } Timber::render($template, $context); ?>