@@ -10,83 +10,83 @@ |
||
| 10 | 10 | class Barista |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - const DEPENDENCY_LIST_REGISTERED = 'registered'; |
|
| 13 | + const DEPENDENCY_LIST_REGISTERED = 'registered'; |
|
| 14 | 14 | |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var AssetManifest |
|
| 18 | - */ |
|
| 19 | - private $asset_manifest; |
|
| 16 | + /** |
|
| 17 | + * @var AssetManifest |
|
| 18 | + */ |
|
| 19 | + private $asset_manifest; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var bool |
|
| 23 | - */ |
|
| 24 | - protected $initialized = false; |
|
| 21 | + /** |
|
| 22 | + * @var bool |
|
| 23 | + */ |
|
| 24 | + protected $initialized = false; |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Barista constructor. |
|
| 29 | - * |
|
| 30 | - * @param AssetManifest $asset_manifest |
|
| 31 | - */ |
|
| 32 | - public function __construct(AssetManifest $asset_manifest) |
|
| 33 | - { |
|
| 34 | - $this->asset_manifest = $asset_manifest; |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * Barista constructor. |
|
| 29 | + * |
|
| 30 | + * @param AssetManifest $asset_manifest |
|
| 31 | + */ |
|
| 32 | + public function __construct(AssetManifest $asset_manifest) |
|
| 33 | + { |
|
| 34 | + $this->asset_manifest = $asset_manifest; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - public function initialize() |
|
| 42 | - { |
|
| 43 | - if (! $this->initialized) { |
|
| 44 | - add_action('wp_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
| 45 | - add_action('admin_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
| 46 | - add_action('wp_enqueue_scripts', [$this, 'registerPackagesStyles'], 0); |
|
| 47 | - add_action('admin_enqueue_scripts', [$this, 'registerPackagesStyles'], 0); |
|
| 48 | - $this->initialized = true; |
|
| 49 | - } |
|
| 50 | - } |
|
| 38 | + /** |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + public function initialize() |
|
| 42 | + { |
|
| 43 | + if (! $this->initialized) { |
|
| 44 | + add_action('wp_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
| 45 | + add_action('admin_enqueue_scripts', [$this, 'registerScripts'], 0); |
|
| 46 | + add_action('wp_enqueue_scripts', [$this, 'registerPackagesStyles'], 0); |
|
| 47 | + add_action('admin_enqueue_scripts', [$this, 'registerPackagesStyles'], 0); |
|
| 48 | + $this->initialized = true; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Registers all the WordPress packages scripts that are in the standardized |
|
| 55 | - * `build/` location. |
|
| 56 | - * |
|
| 57 | - * @return void |
|
| 58 | - */ |
|
| 59 | - public function registerScripts() |
|
| 60 | - { |
|
| 61 | - $entry_points = $this->asset_manifest->getEntryPoints(); |
|
| 62 | - foreach ($entry_points as $entry_point) { |
|
| 63 | - if ($this->asset_manifest->hasAsset($entry_point)) { |
|
| 64 | - $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
| 65 | - $source = $this->asset_manifest->getAssetUrl($entry_point); |
|
| 66 | - $dependencies = $this->asset_manifest->getAssetDependencies($entry_point); |
|
| 67 | - $version = $this->asset_manifest->getAssetVersion($entry_point); |
|
| 68 | - wp_register_script($handle, $source, $dependencies, $version, true); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - } |
|
| 53 | + /** |
|
| 54 | + * Registers all the WordPress packages scripts that are in the standardized |
|
| 55 | + * `build/` location. |
|
| 56 | + * |
|
| 57 | + * @return void |
|
| 58 | + */ |
|
| 59 | + public function registerScripts() |
|
| 60 | + { |
|
| 61 | + $entry_points = $this->asset_manifest->getEntryPoints(); |
|
| 62 | + foreach ($entry_points as $entry_point) { |
|
| 63 | + if ($this->asset_manifest->hasAsset($entry_point)) { |
|
| 64 | + $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
| 65 | + $source = $this->asset_manifest->getAssetUrl($entry_point); |
|
| 66 | + $dependencies = $this->asset_manifest->getAssetDependencies($entry_point); |
|
| 67 | + $version = $this->asset_manifest->getAssetVersion($entry_point); |
|
| 68 | + wp_register_script($handle, $source, $dependencies, $version, true); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Registers all the packages and domain styles that are in the build folder. |
|
| 76 | - * |
|
| 77 | - * @return void |
|
| 78 | - */ |
|
| 79 | - public function registerPackagesStyles() |
|
| 80 | - { |
|
| 81 | - $entry_points = $this->asset_manifest->getEntryPoints(); |
|
| 82 | - foreach ($entry_points as $entry_point) { |
|
| 83 | - if ($this->asset_manifest->hasAsset($entry_point, AssetManifest::ASSET_EXT_CSS)) { |
|
| 84 | - $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
| 85 | - $source = $this->asset_manifest->getAssetUrl($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
| 86 | - $dependencies = $this->asset_manifest->getAssetDependencies($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
| 87 | - $version = $this->asset_manifest->getAssetVersion($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
| 88 | - wp_register_style($handle, $source, $dependencies, $version, 'all'); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 74 | + /** |
|
| 75 | + * Registers all the packages and domain styles that are in the build folder. |
|
| 76 | + * |
|
| 77 | + * @return void |
|
| 78 | + */ |
|
| 79 | + public function registerPackagesStyles() |
|
| 80 | + { |
|
| 81 | + $entry_points = $this->asset_manifest->getEntryPoints(); |
|
| 82 | + foreach ($entry_points as $entry_point) { |
|
| 83 | + if ($this->asset_manifest->hasAsset($entry_point, AssetManifest::ASSET_EXT_CSS)) { |
|
| 84 | + $handle = $this->asset_manifest->getAssetHandle($entry_point); |
|
| 85 | + $source = $this->asset_manifest->getAssetUrl($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
| 86 | + $dependencies = $this->asset_manifest->getAssetDependencies($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
| 87 | + $version = $this->asset_manifest->getAssetVersion($entry_point, AssetManifest::ASSET_EXT_CSS); |
|
| 88 | + wp_register_style($handle, $source, $dependencies, $version, 'all'); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | } |