-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.php
42 lines (38 loc) · 1.02 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Timber Bootstrap
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
// check if Timber is installed
if (!class_exists('Timber')) {
echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
return;
}
// set data in page context
if (is_singular()) {
$context = Timber::get_context();
$context['menu'] = new TimberMenu();
$context['post'] = new TimberPost();
} else {
$context = Timber::get_context();
$context['menu'] = new TimberMenu();
$context['posts'] = Timber::get_posts();
}
// switch template based on page type
if (is_single()) {
$template = 'blog-post/blog-post';
} else if (is_page()) {
$template = 'page/page';
} else if (is_home()) {
$template = 'blog/blog';
} else if (is_category()) {
$template = 'app/app';
} else if (is_tag()) {
$template = 'app/app';
} else if (is_author()) {
$template = 'app/app';
}
Timber::render('modules/'.$template.'.twig', $context);