PluginProbe
Black Bar / trunk
Black Bar vtrunk
trunk 1.0.0 1.1.0 1.2.0 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.2.1 3.0.0 3.1.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0
blackbar / plugin / Modules / Templates.php

Templates.php in Black Bar trunk, at plugin/Modules/Templates.php

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace GeminiLabs\BlackBar\Modules;
4
5 class Templates extends Module
6 {
7 public function entries(): array
8 {
9 if (!empty($this->entries)) {
10 return $this->entries;
11 }
12 if (class_exists('\GeminiLabs\Castor\Facades\Development')
13 && class_exists('\GeminiLabs\Castor\Helpers\Development')
14 && method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line
15 $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths();
16 } else {
17 $files = array_values(array_filter(get_included_files(), function ($file) {
18 $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php');
19 return (bool) apply_filters('blackbar/templates/file', $bool, $file);
20 }));
21 $this->entries = array_map(function ($file) {
22 return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file);
23 }, $files);
24 }
25 return $this->entries;
26 }
27
28 public function hasEntries(): bool
29 {
30 return !empty($this->entries());
31 }
32
33 public function icon(): string
34 {
35 return 'dashicons-welcome-widgets-menus';
36 }
37
38 public function isVisible(): bool
39 {
40 return !is_admin() && $this->hasEntries();
41 }
42
43 public function label(): string
44 {
45 return __('Templates', 'blackbar');
46 }
47 }
48