/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_page()) { $context['segments'] = Timber::get_posts(['post_type' => 'segment', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc']); $context['post'] = new TimberPost(); $template = [$context['post']->_wp_page_template . '.twig', 'page-' . $context['post']->post_name . '.twig', 'page.twig']; } else if (is_post_type_archive('segment')) { $context['posts'] = new Timber\PostQuery(); $template = ['segment-archive.twig']; } else if (is_singular('segment')) { $context['post'] = new TimberPost(); $template = ['segment-single.twig']; } else if (is_search()) { $url = get_home_url(); wp_safe_redirect($url, 301); exit(); } else if (is_404()) { $template = ['errors/404.twig']; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { global $wp; $request = (object) array_map('stripslashes', $_POST); $referer = home_url($wp->request); $error = false; if (empty($request->name)) { $error = 'name'; } if (!filter_var($request->email, FILTER_VALIDATE_EMAIL)) { $error = 'email'; } if (!empty($request->url)) { $error = 'honeypot'; } if (!wp_verify_nonce($request->_wpnonce, 'contact')) { $error = 'nonce'; } if (!$error) { wp_mail(['janjaap@ticketworks.nl', 'service@ticketworks.nl'], 'Vraag van ' . $request->email, $request->question, ['From: contact@ticketworks.nl', 'Cc: ' . $request->name . ' <' . $request->email . '>']); wp_safe_redirect('/bedankt-voor-je-vraag'); exit(); } wp_safe_redirect($referer . '/?error=' . $error); exit(); } Timber::render($template, $context); ?>