This repository was archived by the owner on Mar 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
65 lines (54 loc) · 1.77 KB
/
functions.php
File metadata and controls
65 lines (54 loc) · 1.77 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types = 1);
/**
* If you are installing Timber as a Composer dependency in your theme, you'll need this block
* to load your dependencies and initialize Timber. If you are using Timber via the WordPress.org
* plug-in, you can safely delete this block.
*/
$composer_autoload = get_theme_file_path('/vendor/autoload.php');
if (file_exists($composer_autoload)) {
require_once $composer_autoload;
$timber = new Timber\Timber();
}
/**
* This ensures that Timber is loaded and available as a PHP class.
* If not, it gives an error message to help direct developers on where to activate.
*/
if (!class_exists('Timber')) {
add_action(
'admin_notices',
function () {
echo '<div class="error"><p>This theme will not work until Timber is activated. <a href="' . esc_url(
admin_url('plugins.php#timber')
) . '">Activate the plugin</a> or install it as a Composer dependency.</p></div>';
}
);
add_filter(
'template_include',
function ($template) {
return get_theme_file_path('static/timber.html');
}
);
return;
}
/**
* Sets the directories (inside your theme) to find .twig files
*/
Timber::$dirname = ['templates'];
/**
* By default, Timber does NOT autoescape values. Want to enable Twig's autoescape?
* No prob! Just set this value to true
*/
Timber::$autoescape = false;
/**
* Cache compiled Twig files.
* This does not cache the contents of the variables.
* Best to set to true only when going to production.
*
* See https://timber.github.io/docs/guides/performance/#cache-the-twig-file-but-not-the-data
*/
Timber::$cache = false;
/**
* Instantiate the core theme class.
*/
require_once get_theme_file_path('/inc/BasicWPTheme.php');