diff options
Diffstat (limited to 'src/PluginUsesWordPressScripts.php')
| -rw-r--r-- | src/PluginUsesWordPressScripts.php | 35 | 
1 files changed, 35 insertions, 0 deletions
| diff --git a/src/PluginUsesWordPressScripts.php b/src/PluginUsesWordPressScripts.php new file mode 100644 index 0000000..3a60828 --- /dev/null +++ b/src/PluginUsesWordPressScripts.php @@ -0,0 +1,35 @@ +<?php + +namespace Dweipert\WpEnqueueAssets; + +trait PluginUsesWordPressScripts +{ +    use UsesWordPressScripts; + +    /** +     * Assuming the main plugin class file is in a sub-folder +     * +     * @var string +     */ +    protected string $pluginDir = __DIR__; + +    /** +     * @param string $asset +     * +     * @return string +     */ +    public function assetsUrl(string $asset): string +    { +        return plugin_dir_url($this->pluginDir) . "{$this->buildDir}/$asset"; +    } + +    /** +     * @param string $asset +     * +     * @return array +     */ +    public function assetsMeta(string $asset): array +    { +        return include plugin_dir_path($this->pluginDir) . "{$this->buildDir}/$asset.asset.php"; +    } +} | 
