-
Notifications
You must be signed in to change notification settings - Fork 19
/
functions.php
53 lines (45 loc) · 1.39 KB
/
functions.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
43
44
45
46
47
48
49
50
51
52
53
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
require_once __DIR__ . '/vendor/autoload.php';
use Timber\Site;
class StarterSite extends Site {
function __construct() {
add_theme_support('post-formats');
add_theme_support('post-thumbnails');
add_theme_support('menus');
add_filter('timber_context', array($this, 'add_to_context'));
add_filter('get_twig', array($this, 'add_to_twig'));
add_action('init', array($this, 'register_post_types'));
add_action('init', array($this, 'register_taxonomies'));
parent::__construct();
}
function register_post_types() {
//this is where you can register custom post types
}
function register_taxonomies() {
//this is where you can register custom taxonomies
}
function add_to_context($context) {
$context['menu'] = new Timber\Menu();
$context['site'] = $this;
return $context;
}
function add_to_twig($twig) {
/* this is where you can add your own fuctions to twig */
$twig->addExtension(new Twig_Extension_StringLoader());
/** Example how to add a filter
$twig->addFilter('myfoo', new Twig_SimpleFilter('myfoo', function(){
# some filter code
}));
*/
/** Example how to add a function
$twig->addFunction(new Twig_SimpleFunction($MyTwigFunction',function ($MyArgument1) {
// some code
}));
*/
return $twig;
}
}
new StarterSite();