summaryrefslogtreecommitdiff
path: root/src/UsesWordPressScripts.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/UsesWordPressScripts.php')
-rw-r--r--src/UsesWordPressScripts.php20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/UsesWordPressScripts.php b/src/UsesWordPressScripts.php
index e93a01e..c565575 100644
--- a/src/UsesWordPressScripts.php
+++ b/src/UsesWordPressScripts.php
@@ -7,7 +7,7 @@ trait UsesWordPressScripts
/**
* @var string
*/
- protected $buildDir = 'build';
+ protected string $buildDir = 'build';
/**
* @param string $handle
@@ -15,7 +15,7 @@ trait UsesWordPressScripts
* @param array $deps
* @param bool $inFooter
*/
- public function enqueueScript($handle, $asset, $deps = [], $inFooter = false)
+ public function enqueueScript(string $handle, string $asset, array $deps = [], bool $inFooter = false)
{
$assetBaseName = pathinfo($asset, PATHINFO_FILENAME);
$meta = $this->assetsMeta($assetBaseName);
@@ -35,7 +35,7 @@ trait UsesWordPressScripts
* @param array $deps
* @param string $media
*/
- public function enqueueStyle($handle, $asset, $deps = [], $media = 'all')
+ public function enqueueStyle(string $handle, string $asset, array $deps = [], string $media = 'all')
{
$assetBaseName = pathinfo($asset, PATHINFO_FILENAME);
$meta = $this->assetsMeta($assetBaseName);
@@ -52,20 +52,14 @@ trait UsesWordPressScripts
/**
* @param string $asset
*
- * @return string
+ * @return string Url to asset in $buildDir
*/
- public function assetsUrl($asset)
- {
- return get_stylesheet_directory_uri() . "/{$this->buildDir}/$asset";
- }
+ abstract public function assetsUrl(string $asset): string;
/**
* @param string $asset
*
- * @return mixed
+ * @return array Data from $asset.asset.php in $buildDir
*/
- public function assetsMeta($asset)
- {
- return include get_stylesheet_directory() . "/{$this->buildDir}/$asset.asset.php";
- }
+ abstract public function assetsMeta(string $asset): array;
}