From 3d94a6d9b74be03b58049dd24ff59145f24b36a1 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 9 Oct 2021 19:46:58 +0200 Subject: Splits into two separate Traits for Themes and Plugins --- src/UsesWordPressScripts.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/UsesWordPressScripts.php') 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; } -- cgit v1.2.3