-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
74 lines (59 loc) · 2.02 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
use Timber\Timber;
require_once(__DIR__ . '/vendor/autoload.php');
$timber = new Timber();
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;
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('tw/main.css', get_template_directory_uri() . '/dist/main.css', false, null);
wp_enqueue_script('tw/app.js', get_template_directory_uri() . '/dist/app.js', ['jquery'], null, true);
wp_localize_script('tw/app.js', 'wp', [
'ajaxurl' => admin_url('admin-ajax.php'),
]);
}, 100);
add_action('after_setup_theme', function () {
// Add default posts and comments RSS feed links to head.
add_theme_support('automatic-feed-links');
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']);
add_theme_support('menus');
/**
* Enable features from Soil when plugin is activated
* @link https://roots.io/plugins/soil/
*/
add_theme_support('soil-clean-up');
add_theme_support('soil-nav-walker');
add_theme_support('soil-nice-search');
register_nav_menus([
'primary_navigation' => __('Primary Navigation', 'tw'),
'pages_sidebar' => __('Pages sidebar', 'tw'),
]);
}, 20);
/**
* Register sidebars
*/
add_action('widgets_init', function () {
$config = [
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>'
];
register_sidebar([
'name' => __('Primary', 'tw'),
'id' => 'sidebar-primary'
] + $config);
});
/**
* Adding globals to theme context
*/
add_filter('timber/context', function ($context) {
// access it in template with {{ main_menu }}
$context['main_menu'] = new \Timber\Menu('primary_navigation');
return $context;
});