| 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 |
|