PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.89
WindPress – Tailwind CSS integration for WordPress v3.2.89
3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 143 releases
windpress / src / Integration / Timber / Compile.php

Compile.php in WindPress – Tailwind CSS integration for WordPress 3.2.89, at src/Integration/Timber/Compile.php

50 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the WindPress package.
5 *
6 * (c) Joshua Gugun Siagian <suabahasa@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 declare (strict_types=1);
12 namespace WindPress\WindPress\Integration\Timber;
13
14 use WindPressDeps\Symfony\Component\Finder\Finder;
15 use Timber\LocationManager;
16 use Timber\Timber;
17 use WindPress\WindPress\Core\Scanner\FileScanner;
18 /**
19 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
20 */
21 class Compile
22 {
23 /**
24 * @param array $metadata
25 */
26 public function __invoke($metadata): array
27 {
28 if (!class_exists(Timber::class)) {
29 return [];
30 }
31 return $this->get_contents($metadata);
32 }
33 public function get_contents($metadata): array
34 {
35 return FileScanner::scan_files('timber', static function (): \Generator {
36 $paths = LocationManager::get_locations();
37 $paths = array_unique(array_filter(array_merge(...array_values($paths)), static fn($path) => is_string($path) && $path !== '/' && is_dir($path)));
38 if ($paths === []) {
39 return;
40 }
41 $finder = new Finder();
42 $finder->in($paths)->files()->name('*.twig');
43 do_action('a!windpress/integration/timber/compile:get_contents.finder', $finder);
44 foreach ($finder as $file) {
45 yield ['path' => $file->getPathname(), 'name' => $file->getRelativePathname()];
46 }
47 }, $metadata['next_batch'] ?? \false);
48 }
49 }
50