<?php

require_once('const.php');
$context = array();
$context['theme'] = get_template_directory_uri();

$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
if ($current_user_id == 0) {
    $context['logout'] = array(
        'login' => $const_login_page,
        'register' => $const_register_page
    );
} else {
    $name = $current_user->user_login;
    $role = $current_user->roles[0];
    $user_role = '';
    switch ($role) {
        case 'contributor':
            $user_role = '用户';
            break;
        case 'editor':
            $user_role = '置业顾问';
            header('Location: ' . $const_list_page);
            exit;
            break;
        case 'administrator':
            $user_role = '管理员';
            break;
    }
    $context['login'] = array(
        'name' => $user_role . $name,
        'out' => wp_logout_url($const_login_page)
    );
}
Timber::render('my.html', $context);

?>