-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTheme.php
More file actions
93 lines (81 loc) · 1.62 KB
/
Theme.php
File metadata and controls
93 lines (81 loc) · 1.62 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Class for theme construct
*/
namespace someoddpilot\wptheme;
use Timber;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Theme construct
*/
class Theme
{
/**
* Timber instanc
*
* @type Timber
*/
private $timber;
/**
* Request instance
*
* @type Request
*/
private $request;
/**
* Response instanc
*
* @type Response
*/
private $response;
/**
* Construct instance of controller
*
* @param $timber Timber
* @param $request Request
* @param $response Response
*/
public function __construct(Timber $timber, Request $request, Response $response)
{
$this->timber = $timber;
$this->request = $request;
$this->response = $response;
add_theme_support('post-thumbnails');
add_theme_support('custom-header');
add_theme_support('custom-background');
$this->addFilter('timber_context', array($this, 'addToContext'));
}
/**
* Add controller
*
* @param $controllerClass string
* @return Controller
*/
public function addController($controllerClass)
{
return new $controllerClass($this->timber, $this->request, $this->response);
}
/**
* Add Wordpress filter
*
* @param $filterName string
* @param $callback Callable
*/
public function addFilter($filterName, $callback)
{
add_filter($filterName, $callback);
}
/**
* Add to context
*
* @param $context array
*
* @return array context
*/
public function addToContext(array $context)
{
$context['pageTitle'] = wp_title('|', false, 'right');
return $context;
}
}