Location
2 days ago
Script
2 days ago
Assets.php
2 days ago
Enqueueable.php
2 days ago
Enqueueables.php
2 days ago
Location.php
2 days ago
Script.php
2 days ago
Style.php
2 days ago
Style.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Asset; |
| 6 | |
| 7 | class Style extends Enqueueable |
| 8 | { |
| 9 | public function register(): void |
| 10 | { |
| 11 | if (! $this->location instanceof Location) { |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | $version = $this->get_version(); |
| 16 | |
| 17 | wp_register_style( |
| 18 | $this->get_handle(), |
| 19 | $this->location->get_url(), |
| 20 | $this->dependencies, |
| 21 | $version !== null |
| 22 | ? (string)$version |
| 23 | : null |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | public function enqueue(): void |
| 28 | { |
| 29 | if (wp_style_is($this->get_handle())) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | if (! wp_style_is($this->get_handle(), 'registered')) { |
| 34 | $this->register(); |
| 35 | } |
| 36 | |
| 37 | wp_enqueue_style($this->get_handle()); |
| 38 | } |
| 39 | |
| 40 | } |
| 41 |