/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(); $context['post'] = new Link050Post(); $context['contact'] = get_fields('option'); $context['news_index_url'] = get_permalink(61); $context['vacancy_index_url'] = get_permalink(827); $context['course_index_url'] = get_permalink(592); $context['participate_index_url'] = get_permalink(1004); $context['menu_image'] = new TimberImage(get_stylesheet_directory() . '/images/mobile.svg'); $context['facebook_image'] = new TimberImage(get_stylesheet_directory() . '/images/facebook.jpg'); $context['linkedin_image'] = new TimberImage(get_stylesheet_directory() . '/images/linkedin.png'); $context['print_image'] = new TimberImage(get_stylesheet_directory() . '/images/printer.png'); if (!empty($_GET['s'])) { $context['search'] = $_GET['s']; } if (is_front_page()) { $template = ['home.twig']; } elseif (is_search()) { $context['title'] = get_search_query(); $template = ['page-search.twig']; } elseif (is_page('contact')) { $template = ['contact.twig']; } // // oude vacature search // elseif (is_page('vrijwilligersvacaturebank')) { // if (! empty($_GET['vacancy_id'])) { // $context['vacancy'] = new VacancyPost(); // $context['vacancy'] = $context['vacancy']->single_vacancy($_GET['vacancy_id']); // $template = ['vacancy-single.twig']; // } else { // $context['vacancy'] = new VacancyPost(); // $template = ['vacancies-index.twig']; // } // } elseif(preg_match('/^\/vrijwilligerswerk\/vrijwilligersvacaturebank\/(.*)\/(.*)$/m', $_SERVER['REQUEST_URI'], $matches)) { $query_string = ''; $slug = ''; if(strpos($matches[2], '?preview_token=')){ $parts = explode('?', $matches[2]); $query_string = end($parts); $slug = $parts[0]; } else { $slug = $matches[2]; } $api = vacancy_api_call('/vacancy/' . $matches[1] . '?' . $query_string, false, null, true); if(is_array($api) === false || $slug !== $api['data']['slug']) { $template = ['errors/404.twig']; $context['post']->update('post_type', 'vacancy'); $context['post']->update('wp_title', 'Vacature niet gevonden'); $context['post']->update('breadcrumb_title', 'Vacature niet gevonden'); $context['post']->update('breadcrumb_link', '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } else { $context['vacancy'] = $api['data']; $template = ['vacancy-show.twig']; $context['post']->update('post_type', 'vacancy'); $context['post']->update('wp_title', $api['data']['title']); $context['post']->update('breadcrumb_title', $api['data']['title']); $context['post']->update('breadcrumb_link', '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); // Overwrite wp_title to prevent not found title $context['wp_title'] = $api['data']['title']; // Update status header to prevent 404 status_header(200); } } // nieuwe vacature search elseif (strpos($_SERVER['REQUEST_URI'], 'vrijwilligersvacaturebank')) { $context['vacancy'] = new VacancyPost(); $context['api'] = vacancy_api_call('/vacancies', false, null, true); $template = ['vacancy-search.twig']; } elseif (is_page('nieuws')) { $template = ['news-index.twig']; } elseif (is_page('nieuws-archief')) { $template = ['news-archive.twig']; } // old course search index elseif (is_page(592)) { $template = ['temp-no-courses.twig']; } // Ontwikkellink search index elseif (is_page(3995)) { $context['api'] = course_api_call('/courses', false, null, true); $template = ['course-index.twig']; } elseif (is_singular('elearning')) { $context['post'] = new TimberPost(); $template = ['single-elearning.twig']; } elseif (is_singular('participate_vacancy')) { $context['vacancy'] = new ParticipateVacancyPost(); if ($context['vacancy']->doelgroepen) { $all_groups = get_field_object('doelgroepen')['choices']; $vacancy_groups = []; foreach ($context['vacancy']->doelgroepen as $key => $value) { $vacancy_groups[$key] = $all_groups[$value]; } $context['vacancy']->doelgroepen = $vacancy_groups; } if ($context['vacancy']->activiteiten) { $all_activities = get_field_object('activiteiten')['choices']; $vacancy_activities = []; foreach ($context['vacancy']->activiteiten as $key => $value) { $vacancy_activities[$key] = $all_activities[$value]; } $context['vacancy']->activiteiten = $vacancy_activities; } if ($context['vacancy']->werksoort) { $all_worktypes = get_field_object('werksoort'); $context['vacancy']->werksoort = $all_worktypes['choices'][$all_worktypes['value']]; } $all_locations = get_field_object('locatie'); if ($context['vacancy']->locatie == 'spec') { $all_blocks = get_field_object('wijken'); $vacancy_blocks = []; foreach ($all_blocks['value'] as $key => $value) { $vacancy_blocks[$key] = $all_blocks['choices'][$value]; } $context['vacancy']->locatie = $vacancy_blocks; } else { $context['vacancy']->locatie = [$all_locations['choices'][$all_locations['value']]]; } $template = ['participate-vacancy-single.twig']; } elseif (is_page(1004)) { $context['vacancy'] = new ParticipateVacancyPost(); $template = ['participate-vacancies-index.twig']; } elseif (is_page()) { $template = ['page-single.twig']; } elseif (is_singular()) { $template = ['post-single.twig']; } elseif (is_404()) { $template = ['errors/404.twig']; } $context['template'] = $template[0]; Timber::render($template, $context);