|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the WPFoundation library. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2015-2016 LIN3S <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace LIN3S\WPFoundation\Configuration\Theme; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Abstract class of theme that implements the interface. |
|
16
|
|
|
* This class avoids the use of callbacks in the constructor. |
|
17
|
|
|
* |
|
18
|
|
|
* @author Beñat Espiña <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
abstract class Theme implements ThemeInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Constructor. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->classes(); |
|
28
|
|
|
$this->templateSelector(); |
|
|
|
|
|
|
29
|
|
|
add_theme_support('post-thumbnails'); |
|
|
|
|
|
|
30
|
|
|
add_filter('timber_context', [$this, 'context']); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
// @deprecated since version 1.6, will be removed in 2.0. Extend the ACF class in your project and instantiate |
|
33
|
|
|
// inside your project Theme. |
|
34
|
|
|
$this->acf(); |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Filters the selectable templates. |
|
39
|
|
|
*/ |
|
40
|
|
|
private function templateSelector() |
|
41
|
|
|
{ |
|
42
|
|
|
$self = $this; |
|
43
|
|
|
add_filter('theme_page_templates', function () use ($self) { |
|
|
|
|
|
|
44
|
|
|
return $self->templates([]); |
|
45
|
|
|
}); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @deprecated since version 1.6, will be removed in 2.0. Extend the ACF class in your project and instantiate |
|
50
|
|
|
* inside your project Theme. |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function acf() |
|
53
|
|
|
{ |
|
54
|
|
|
$customToolbars = [ |
|
55
|
|
|
'lin3s' => [1 => ['bold', 'italic', 'bullist', 'numlist', 'link', 'unlink']], |
|
56
|
|
|
]; |
|
57
|
|
|
|
|
58
|
|
|
add_filter('acf/fields/wysiwyg/toolbars', function (array $toolbars) use ($customToolbars) { |
|
|
|
|
|
|
59
|
|
|
return array_merge($toolbars, $customToolbars); |
|
60
|
|
|
}); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call: