1 | <?php |
||
20 | class TimberTheme extends TimberCore { |
||
21 | |||
22 | /** |
||
23 | * @api |
||
24 | * @var string the human-friendly name of the theme (ex: `My Timber Starter Theme`) |
||
25 | */ |
||
26 | public $name; |
||
27 | |||
28 | /** |
||
29 | * @api |
||
30 | * @var TimberTheme|bool the TimberTheme object for the parent theme (if it exists), false otherwise |
||
31 | */ |
||
32 | public $parent = false; |
||
33 | |||
34 | /** |
||
35 | * @api |
||
36 | * @var string the slug of the parent theme (ex: `_s`) |
||
37 | */ |
||
38 | public $parent_slug; |
||
39 | |||
40 | /** |
||
41 | * @api |
||
42 | * @var string the slug of the theme (ex: `my-super-theme`) |
||
43 | */ |
||
44 | public $slug; |
||
45 | public $uri; |
||
46 | |||
47 | /** |
||
48 | * Constructs a new TimberTheme object. NOTE the TimberTheme object of the current theme comes in the default `Timber::get_context()` call. You can access this in your twig template via `{{site.theme}}. |
||
49 | * @param string $slug |
||
|
|||
50 | * @example |
||
51 | * ```php |
||
52 | * <?php |
||
53 | * $theme = new TimberTheme("my-theme"); |
||
54 | * $context['theme_stuff'] = $theme; |
||
55 | * Timber::render('single.') |
||
56 | * ?> |
||
57 | * ``` |
||
58 | * ```twig |
||
59 | * We are currently using the {{ theme_stuff.name }} theme. |
||
60 | * ``` |
||
61 | * ```html |
||
62 | * We are currently using the My Theme theme. |
||
63 | * ``` |
||
64 | */ |
||
65 | function __construct($slug = null) { |
||
68 | |||
69 | /** |
||
70 | * @internal |
||
71 | * @param string $slug |
||
72 | */ |
||
73 | protected function init($slug = null) { |
||
74 | $data = wp_get_theme($slug); |
||
75 | $this->name = $data->get('Name'); |
||
76 | $ss = $data->get_stylesheet(); |
||
77 | $this->slug = $ss; |
||
78 | |||
79 | if ( ! function_exists( 'get_home_path' ) ) { |
||
80 | require_once(ABSPATH . 'wp-admin/includes/file.php'); |
||
81 | } |
||
82 | |||
83 | $this->uri = get_stylesheet_directory_uri(); |
||
84 | $this->parent_slug = $data->get('Template'); |
||
85 | if ( !$this->parent_slug ) { |
||
86 | $this->uri = get_template_directory_uri(); |
||
87 | } |
||
88 | if ( $this->parent_slug && $this->parent_slug != $this->slug ) { |
||
89 | $this->parent = new TimberTheme($this->parent_slug); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @api |
||
95 | * @return string the absolute path to the theme (ex: `http://example.org/wp-content/themes/my-timber-theme`) |
||
96 | */ |
||
97 | public function link() { |
||
100 | |||
101 | /** |
||
102 | * @api |
||
103 | * @return string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`) |
||
104 | */ |
||
105 | public function path() { |
||
108 | |||
109 | /** |
||
110 | * @param string $name |
||
111 | * @param bool $default |
||
112 | * @return string |
||
113 | */ |
||
114 | public function theme_mod($name, $default = false) { |
||
117 | |||
118 | /** |
||
119 | * @return array |
||
120 | */ |
||
121 | public function theme_mods() { |
||
124 | |||
125 | } |
||
126 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.