Location
1 month ago
Script
1 month ago
Assets.php
1 month ago
Enqueueable.php
1 month ago
Enqueueables.php
1 month ago
Location.php
1 month ago
Script.php
1 month ago
Style.php
1 month ago
Enqueueable.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Asset; |
| 6 | |
| 7 | abstract class Enqueueable |
| 8 | { |
| 9 | |
| 10 | protected string $handle; |
| 11 | |
| 12 | protected ?Location $location; |
| 13 | |
| 14 | protected array $dependencies; |
| 15 | |
| 16 | public function __construct(string $handle, ?Location $location = null, array $dependencies = []) |
| 17 | { |
| 18 | $this->handle = $handle; |
| 19 | $this->location = $location; |
| 20 | $this->dependencies = $dependencies; |
| 21 | } |
| 22 | |
| 23 | public function get_handle(): string |
| 24 | { |
| 25 | return $this->handle; |
| 26 | } |
| 27 | |
| 28 | protected function get_version(): ?int |
| 29 | { |
| 30 | $path = $this->location->get_path(); |
| 31 | |
| 32 | return file_exists($path) |
| 33 | ? filemtime($path) |
| 34 | : null; |
| 35 | } |
| 36 | |
| 37 | abstract public function register(): void; |
| 38 | |
| 39 | abstract public function enqueue(): void; |
| 40 | |
| 41 | } |