Scripts.php
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace AC\Admin;
use AC\Asset\Location\Absolute;
use AC\Asset\Script;
use AC\Asset\Style;
use AC\Registerable;
class Scripts implements Registerable
{
private $location;
public function __construct(Absolute $location)
{
$this->location = $location;
}
public function register(): void
{
add_action('init', [$this, 'register_scripts']);
}
public function register_scripts(): void
{
$assets = [
new Script('ac-select2-core', $this->location->with_suffix('assets/js/select2.js')),
new Script(
'ac-select2',
$this->location->with_suffix('assets/js/select2_conflict_fix.js'),
['jquery', 'ac-select2-core']
),
new Style('ac-select2', $this->location->with_suffix('assets/css/select2.css')),
new Style('ac-jquery-ui', $this->location->with_suffix('assets/css/ac-jquery-ui.css')),
];
foreach ($assets as $asset) {
$asset->register();
}
}
}