summaryrefslogtreecommitdiff
path: root/src/PluginUsesWordPressScripts.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-10-09 19:46:58 +0200
committerDaniel Weipert <code@drogueronin.de>2021-10-09 19:46:58 +0200
commit3d94a6d9b74be03b58049dd24ff59145f24b36a1 (patch)
treea4b8b05f552db447ad84c17f8cd41bd63774ef04 /src/PluginUsesWordPressScripts.php
parent52f7203992e1c8662d421e7287e1e1e5f1c2b7cd (diff)
Splits into two separate Traits for Themes and Pluginsv2.0.0
Diffstat (limited to 'src/PluginUsesWordPressScripts.php')
-rw-r--r--src/PluginUsesWordPressScripts.php35
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";
+ }
+}