-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
48 lines (34 loc) · 1.4 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
<?php
require __DIR__ . '/application.php';
if ( ! class_exists( 'Timber' ) ) {
add_action( 'admin_notices', function () {
echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . esc_url( admin_url( 'plugins.php#timber' ) ) . '">' . esc_url( admin_url( 'plugins.php' ) ) . '</a></p></div>';
} );
add_filter( 'template_include', function ( $template ) {
return get_stylesheet_directory() . '/static/no-timber.html';
} );
return;
}
Timber::$dirname = array( 'templates', 'views' );
class StarterSite extends TimberSite {
function __construct() {
add_theme_support( 'post-formats' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'menus' );
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
add_filter( 'timber_context', array( $this, 'add_to_context' ) );
add_filter( 'get_twig', array( $this, 'add_to_twig' ) );
parent::__construct();
}
function add_to_context( $context ) {
$context['menu'] = new TimberMenu();
$context['site'] = $this;
return $context;
}
function add_to_twig( $twig ) {
/* this is where you can add your own functions to twig */
$twig->addExtension( new Twig_Extension_StringLoader() );
return $twig;
}
}
new StarterSite();