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