diff options
| author | Daniel Weipert <code@drogueronin.de> | 2021-10-09 19:46:58 +0200 | 
|---|---|---|
| committer | Daniel Weipert <code@drogueronin.de> | 2021-10-09 19:46:58 +0200 | 
| commit | 3d94a6d9b74be03b58049dd24ff59145f24b36a1 (patch) | |
| tree | a4b8b05f552db447ad84c17f8cd41bd63774ef04 /src/UsesWordPressScripts.php | |
| parent | 52f7203992e1c8662d421e7287e1e1e5f1c2b7cd (diff) | |
Splits into two separate Traits for Themes and Pluginsv2.0.0
Diffstat (limited to 'src/UsesWordPressScripts.php')
| -rw-r--r-- | src/UsesWordPressScripts.php | 20 | 
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;  }  | 
