-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
77 lines (65 loc) · 1.45 KB
/
Copy pathfunctions.php
File metadata and controls
77 lines (65 loc) · 1.45 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
66
67
68
69
70
71
72
73
74
75
76
77
<?php
require_once __DIR__ . '/config/twig.config.php';
require_once __DIR__ . '/config/vite.config.php';
class Theme
{
public function __construct()
{
self::site_config();
self::theme_support();
self::add_twig_function();
}
private function site_config()
{
global $context;
$context['site'] = array(
'locale' => get_language_attributes(),
'url' => site_url(),
'description' => get_bloginfo('description'),
'charset' => get_bloginfo('charset'),
'pingback_url' => get_bloginfo('pingback_url'),
);
}
private function theme_support()
{
add_theme_support('automatic-feed-links');
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support(
'html5',
array(
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
add_theme_support(
'post-formats',
array(
'aside',
'image',
'video',
'quote',
'link',
'gallery',
'audio',
)
);
add_theme_support('menus');
}
private function add_twig_function()
{
global $twig;
$twig->addFunction(new \Twig\TwigFunction('wp_head', function () {
do_action('wp_head');
}));
$twig->addFunction(new \Twig\TwigFunction('wp_footer', function () {
do_action('wp_footer');
}));
$twig->addFunction(new \Twig\TwigFunction('body_class', function ($css_class = '') {
echo 'class="' . esc_attr(implode(' ', get_body_class($css_class))) . '"';
}));
}
}
new Theme();