OTGS_Assets_Handles.php
1 month ago
OTGS_Assets_Store.php
1 month ago
OTGS_UI_Assets.php
1 month ago
OTGS_UI_Loader.php
1 month ago
OTGS_UI_Loader.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | class OTGS_UI_Loader { |
| 4 | |
| 5 | private $assets; |
| 6 | |
| 7 | private $store; |
| 8 | |
| 9 | public function __construct( $locator = null, $assets = null ) { |
| 10 | if ( |
| 11 | ! ( $locator instanceof OTGS_Assets_Store ) |
| 12 | || ! ( $assets instanceof OTGS_UI_Assets ) |
| 13 | ) { |
| 14 | throw new InvalidArgumentException( 'Missing assets and assets store' ); |
| 15 | } |
| 16 | |
| 17 | $this->store = $locator; |
| 18 | $this->assets = $assets; |
| 19 | } |
| 20 | |
| 21 | public function load() { |
| 22 | add_action( 'init', array( $this, 'register' ), 1 ); |
| 23 | } |
| 24 | |
| 25 | public function register() { |
| 26 | $this->store->add_assets_location( __DIR__ . '/../../dist/assets.json' ); |
| 27 | $this->assets->register(); |
| 28 | } |
| 29 | } |
| 30 |