PluginProbe
Auto Alt Text / 2.4.2
Auto Alt Text v2.4.2
3.0.3 2.8.2 1.3.1 1.3.2 2.0.0 2.1.0 2.1.1 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.7.0 2.8.0 2.8.1 All 28 releases
auto-alt-text / src / App / Utilities / AssetsManager.php

AssetsManager.php in Auto Alt Text 2.4.2, at src/App/Utilities/AssetsManager.php

37 lines 755 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AATXT\App\Utilities;
4
5 final class AssetsManager
6 {
7 public function __construct()
8 {
9 }
10
11 public static function make(): AssetsManager
12 {
13 return new self();
14 }
15
16 public function getAssetUrl(string $filename, bool $isStyle = false): string
17 {
18 $manifestPath = AATXT_ABSPATH . '/dist/.vite/manifest.json';
19
20 if (!file_exists($manifestPath)) {
21 return '';
22 }
23
24 $manifest = json_decode(file_get_contents($manifestPath), true);
25
26 $entry = $manifest[$filename] ?? null;
27
28 if (!$entry) {
29 return '';
30 }
31 $file = $isStyle && isset($entry['css']) ? $entry['css'][0] : $entry['file'];
32
33 return AATXT_URL . 'dist/' . $file;
34 }
35
36 }
37