<?php

namespace core_next;

class Route
{
    static function init()
    {
        $path = Config::$theme_dir . "/template/views";
        self::loadHeader();
        if (is_home()) {
            require_once "$path/home.php";
        } elseif (is_single()) {
            require_once "$path/single.php";
        } elseif (is_page()) {
            require_once "$path/page.php";
        } else if (is_author()) {
            require_once "$path/author.php";
        } elseif (is_archive()) {
            require_once "$path/archive.php";
        } else if (is_search()) {
            require_once "$path/search.php";
        } else if (is_404()) {
            require_once "$path/404.php";
        }
    }

    static function loadHeader()
    {
        $path = Config::$theme_dir . "/template/views";
        add_action('wp_head', function () use ($path) {
            require_once "$path/header.php";
        });
    }
}