/wp-admin/plugins.php'; return; } if (!class_exists('WooCommerce')) { echo 'WooCommerce not activated. Make sure you activate the plugin in /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 = ['key' => 'event_datetime', 'value' => date('Y-m-d H:i:s'), 'compare' => '>=', 'type' => 'DATETIME']; $highlight = get_field('news_highlight', 'option'); $context['post'] = new TimberPost(); $context['events'] = Timber::get_posts(['numberposts' => 4, 'post_type' => 'event', 'orderby' => ['meta_value' => 'asc'], 'meta_key' => 'event_datetime', 'meta_query' => [$meta_query]]); if ($highlight) { $context['news'] = Timber::get_posts(['numberposts' => 2, 'post_type' => 'news', 'post__not_in' => [$highlight]]); $context['highlight'] = new TimberPost($highlight); } else { $context['news'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'news']); $context['highlight'] = array_shift($context['news']); } $template = ['home.twig']; } else if (is_post_type_archive('news')) { $post_type = get_queried_object(); $page = get_page_by_path($post_type->rewrite['slug']); $highlight = get_field('news_highlight', 'option'); $context['page'] = new TimberPost($page->ID); $context['highlight'] = $highlight ? new TimberPost($highlight) : false; $context['posts'] = new Timber\PostQuery(); $template = ['news-archive.twig']; } else if (is_singular('news')) { $context['post'] = new TimberPost(); $context['themes'] = $context['post']->get_field('theme'); $context['author'] = $context['post']->get_field('is_blog') ? $context['post']->get_field('author') : null; $template = ['news-single.twig']; } else if (is_post_type_archive('event')) { $post_type = get_queried_object(); $page = get_page_by_path($post_type->rewrite['slug']); $highlight = get_field('event_highlight', 'option'); $context['page'] = new TimberPost($page->ID); $context['highlight'] = $highlight ? new TimberPost($highlight) : false; $context['posts'] = new Timber\PostQuery(); $template = ['event-archive.twig']; } else if (is_singular('event')) { $post = new TimberPost(); if ($id = get_post_meta($post->id, 'training_event', true)) { $training = new TimberPost($id); wp_redirect($training->link, 301); exit; } $context['post'] = $post; $context['themes'] = $context['post']->get_field('theme'); $template = ['event-single.twig']; } else if (is_post_type_archive('people')) { $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(); $context['terms'] = get_field('organisation', 'option'); $context['terms'] = empty($context['terms']) ? Timber::get_terms('organisation', ['orderby' => 'title', 'hide_empty' => true]) : $context['terms']; $context['themes'] = get_field('theme', 'option'); $context['themes'] = empty($context['themes']) ? Timber::get_posts(['numberposts' => -1, 'post_type' => 'theme', 'orderby' => ['title' => 'asc']]) : $context['themes']; foreach ($context['themes'] as $key => $theme) { $context['themes'][$key] = new TimberPost($theme); $context['themes'][$key]->posts = []; foreach ($posts as $post) { $items = get_field('themes', $post->id, false); if (in_array($theme->ID, $items)) { $context['themes'][$key]->posts[] = new TimberPost($post); } } } $template = ['people-archive.twig']; } else if (is_singular('people')) { $context['post'] = new TimberPost(); $context['blogs'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'news', 'meta_query' => [ ['key' => 'is_blog', 'value' => '1'], [ 'relation' => 'OR', ['key' => 'author', 'value' => $context['post']->id], ['key' => 'author', 'value' => sprintf(':"%s";', $context['post']->id), 'compare' => 'LIKE'] ] ]]); $template = ['people-single.twig']; } else if (is_post_type_archive('theme')) { $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 = ['theme-archive.twig']; } else if (is_singular('theme')) { $context['post'] = new TimberPost(); if (!get_query_var('theme_map')) { $meta_query = [['key' => 'themes', 'value' => ':"' . $context['post']->id . '";', 'compare' => 'LIKE']]; $context['people'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'people', 'meta_query' => [$meta_query]]); $template = ['theme-single.twig']; } else { if (!in_array($context['post']->post_name , ['meisjesbesnijdenis-vgv'])) { status_header(404); Timber::render('errors/404.twig', $context); } $context['countries'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'theme_map']); $context['embed'] = isset($_GET['embed']); $template = ['theme-map.twig']; } } else if (is_post_type_archive('training')) { global $wp_query; $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(); $context['count'] = $wp_query->found_posts; $context['filters'] = $_GET; $context['topics'] = Timber::get_terms('topic', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $template = ['training-archive.twig']; } else if (is_singular('training')) { $context['post'] = new TimberPost(); $template = ['training-single.twig']; if (isset($_GET['print'])) { $context['pdf'] = true; } if (isset($_POST['pdf'])) { to_pdf($template, $context, 'training-' . $context['post']->post_name . '.pdf'); } } else if (is_post_type_archive('factsheet')) { wp_redirect(get_home_url(), 301); exit; } else if (is_singular('factsheet')) { $context['post'] = new TimberPost(); $template = ['factsheet-single.twig']; if (isset($_GET['print'])) { $context['pdf'] = true; } if (isset($_POST['pdf'])) { to_pdf($template, $context, 'factsheet-' . $context['post']->post_name . '.pdf'); } } else if (is_post_type_archive('infosheet')) { wp_redirect(get_home_url(), 301); exit; } else if (is_singular('infosheet')) { $context['post'] = new TimberPost(); $template = ['infosheet-single.twig']; if (isset($_GET['print'])) { $context['pdf'] = true; } if (isset($_POST['pdf'])) { to_pdf($template, $context, 'infosheet-' . $context['post']->post_name . '.pdf'); } } else if (is_post_type_archive('contact')) { global $wp_query; $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(); $context['count'] = $wp_query->found_posts; $context['filters'] = ['zoeken' => $_GET['zoeken'] ?: false, 'onderwerp' => isset($_GET['onderwerp']) ? explode(',', $_GET['onderwerp']) : false, 'taal' => isset($_GET['taal']) ? explode(',', $_GET['taal']) : false]; $context['spoken'] = Timber::get_terms('spoken', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $context['subjects'] = Timber::get_terms('subject', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $template = ['contact-archive.twig']; } else if (is_singular('contact')) { $url = get_post_type_archive_link('contact'); wp_redirect($url, 301); exit; } else if (is_post_type_archive('body')) { Timber::$locations = dirname(__FILE__) . '/begrijpjelichaam/views'; $context['themes'] = Timber::get_posts(['post_parent' => 0, 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc', 'post_type' => 'body', 'meta_query' => [['key' => 'type', 'value' => 'theme']]]); $context['posts'] = new Timber\PostQuery(); $template = ['body-archive.twig']; } else if (is_singular('body')) { Timber::$locations = dirname(__FILE__) . '/begrijpjelichaam/views'; $context['themes'] = Timber::get_posts(['post_parent' => 0, 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc', 'post_type' => 'body', 'meta_query' => [['key' => 'type', 'value' => 'theme']]]); $context['post'] = new TimberPost(); $template = ['body-single.twig']; } else if (is_shop()) { global $wp_query, $wpdb; $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(); $context['count'] = $wp_query->found_posts; $context['filters'] = $_GET; if (!is_paged()) { $highlights = get_field('product_highlight', 'option'); $highlights = !empty($highlights) ? $highlights : [0]; $highlights = Timber::get_posts(['numberposts' => -1, 'post_type' => 'product', 'post__in' => $highlights]); $context['highlights'] = $highlights; $context['count'] += count($highlights); } $context['themes'] = get_posts('post_type=theme&posts_per_page=-1'); $context['themes'] = Timber::get_posts($context['themes']); $context['audiences'] = Timber::get_terms('audience', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $context['languages'] = Timber::get_terms('language', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $context['issues'] = Timber::get_terms('issue', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $context['types'] = Timber::get_terms('type', ['orderby' => 'name', 'order' => 'asc', 'show_empty' => false]); $template = ['product-archive.twig']; } else if (is_product_category() || is_product_tag()) { $url = wc_get_page_permalink('shop'); wp_redirect($url, 301); exit; } else if (is_product()) { $post = new TimberPost(); if ($id = $post->get_field('factsheet_product')) { $url = get_permalink($id); wp_safe_redirect($url, 303); exit; } if ($id = $post->get_field('infosheet_product')) { $url = get_permalink($id); wp_safe_redirect($url, 303); exit; } $context['post'] = $post; $context['themes'] = $context['post']->get_field('theme'); $context['product'] = wc_get_product( $context['post']->ID ); $template = ['product-single.twig']; } else if (is_cart()) { $context['post'] = new TimberPost(); $template = ['woocommerce-cart.twig']; } else if (is_checkout()) { $context['post'] = new TimberPost(); $template = ['woocommerce-checkout.twig']; } else if (is_account_page()) { global $woocommerce; if (!$woocommerce->checkout->is_registration_enabled()) { $url = wc_get_page_permalink('cart'); wp_redirect($url, 301); exit; } $context['post'] = new TimberPost(); $template = ['woocommerce-account.twig']; } else if (is_page()) { $post = new TimberPost(); $context['post'] = $post; $context['toc'] = has_toc($post); $template = [$context['post']->_wp_page_template . '.twig', 'page.twig']; if (isset($_POST['pdf'])) { to_pdf($template, $context, $context['post']->post_name . '.pdf'); } } else if (is_search()) { $context['posts'] = new Timber\PostQuery(); $template = ['search.twig']; } else if (is_404()) { if (isset($_POST['cart'])) { status_header(200); $status = ['cart' => $context['cart']]; $json = json_encode($status); exit($json); } $template = ['errors/404.twig']; } if (isset($context['post']) && post_password_required($context['post']->ID)) { $template = 'page-password.twig'; } Timber::render($template, $context); ?>