diff --git a/.ddev/config.yaml b/.ddev/config.yaml
index 936b582..f107f71 100644
--- a/.ddev/config.yaml
+++ b/.ddev/config.yaml
@@ -2,7 +2,7 @@ name: Assets
type: wordpress
docroot: .ddev/wordpress
php_version: "8.2"
-webserver_type: nginx-fpm
+webserver_type: apache-fpm
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml
new file mode 100644
index 0000000..02b915b
--- /dev/null
+++ b/.idea/git_toolbox_prj.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 359856d..1bdb999 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,6 +1,8 @@
+
+
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
index 58cea66..4d0fdb8 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -85,7 +85,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9a09003..57a61a9 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,41 +4,38 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -59,6 +56,7 @@
+
@@ -90,7 +88,9 @@
-
+
+
+
@@ -178,20 +178,24 @@
- {
+ "keyToString": {
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "WebServerToolWindowFactoryState": "false",
+ "last_opened_file_path": "/Users/inpsydematic/Projects/Assets/assets-plugin",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.stylelint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.stylelint": "",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "php.override.implement.member.chooser.php.doc": "NONE",
+ "settings.editor.selected.configurable": "settings.php.debug.servers",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -200,10 +204,6 @@
-
-
-
-
@@ -218,11 +218,42 @@
1721294368548
-
+
+
+
+
+
+
+ 1721368049028
+
+
+
+ 1721368049028
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/src/Caching/IgnoreW3TotalCache.php
+ 11
+
+
+
+ file://$PROJECT_DIR$/.ddev/wordpress/wp-content/plugins/sg-cachepress/core/Minifier/Minifier.php
+ 150
+
+
+
+
+
\ No newline at end of file
diff --git a/assets-plugin/assets-plugin.php b/assets-plugin/assets-plugin.php
index 12d8330..3267458 100644
--- a/assets-plugin/assets-plugin.php
+++ b/assets-plugin/assets-plugin.php
@@ -9,3 +9,29 @@
* Author URI:
* License: MIT
*/
+
+require __DIR__ . '/vendor/autoload.php';
+
+use Inpsyde\Assets\AssetManager;
+use Inpsyde\Assets\Script;
+use Inpsyde\Assets\Style;
+
+add_action(
+ AssetManager::ACTION_SETUP,
+ function(AssetManager $assetManager) {
+ $testScript = new Script('assets-plugin-script', plugin_dir_url(__FILE__) . 'resources/test-script.js');
+ $testScript2 = new Script('assets-plugin-script-2', plugin_dir_url(__FILE__) . 'resources/test-script-2.js');
+
+ $testScript->isInHeader();
+ $testScript2->isInHeader();
+
+ $assetManager->register(
+ $testScript,
+ $testScript2,
+ new Style('assets-plugin-style', plugin_dir_url(__FILE__) . 'resources/test-style.css'),
+ new Style('assets-plugin-style-2', plugin_dir_url(__FILE__) . 'resources/test-style-2.css')
+ );
+
+ $assetManager->ignoreCache();
+ }
+);
\ No newline at end of file
diff --git a/assets-plugin/resources/test-script-2.js b/assets-plugin/resources/test-script-2.js
new file mode 100644
index 0000000..fb3b9ea
--- /dev/null
+++ b/assets-plugin/resources/test-script-2.js
@@ -0,0 +1,7 @@
+document.addEventListener('DOMContentLoaded', function(){
+ sayHelloAgain();
+})
+
+function sayHelloAgain(){
+ console.log('HELLO AGAIN!');
+}
\ No newline at end of file
diff --git a/assets-plugin/resources/test-script.js b/assets-plugin/resources/test-script.js
new file mode 100644
index 0000000..869836b
--- /dev/null
+++ b/assets-plugin/resources/test-script.js
@@ -0,0 +1,7 @@
+document.addEventListener('DOMContentLoaded', function(){
+ sayHello();
+})
+
+function sayHello(){
+ console.log('HELLO!');
+}
\ No newline at end of file
diff --git a/assets-plugin/resources/test-style-2.css b/assets-plugin/resources/test-style-2.css
new file mode 100644
index 0000000..cf77d4e
--- /dev/null
+++ b/assets-plugin/resources/test-style-2.css
@@ -0,0 +1,3 @@
+body{
+ opacity: 0.99;
+}
\ No newline at end of file
diff --git a/assets-plugin/resources/test-style.css b/assets-plugin/resources/test-style.css
new file mode 100644
index 0000000..5cbda45
--- /dev/null
+++ b/assets-plugin/resources/test-style.css
@@ -0,0 +1,3 @@
+body{
+ background:#f0f0f0 !important;
+}
\ No newline at end of file
diff --git a/docs/assets.md b/docs/assets.md
index 09316ac..dddb833 100644
--- a/docs/assets.md
+++ b/docs/assets.md
@@ -55,9 +55,9 @@ The version can be set in different ways and even autogenerated based on the fil
use Inpsyde\Assets\Script;
use Inpsyde\Assets\Style;
-$script = new Script('foo', 'www.example.com/script.js');
+$script = new Script('foo', 'www.example.com/test-script.js');
$script
- ->withFilePath('/path/to/script.js')
+ ->withFilePath('/path/to/test-script.js')
->disableAutodiscoverVersion()
->enableAutodiscoverVersion()
->withVersion('1.0');
@@ -79,7 +79,7 @@ You can enqueue your Assets conditionally by using following API:
use Inpsyde\Assets\Script;
use Inpsyde\Assets\Style;
-$script = new Script('foo', 'www.example.com/script.js');
+$script = new Script('foo', 'www.example.com/test-script.js');
$script->canEnqueue(true);
$style = new Style('foo', 'www.example.com/style.css');
@@ -115,7 +115,7 @@ use Inpsyde\Assets\Script;
use Inpsyde\Assets\Style;
use Inpsyde\Assets\Asset;
-$script = new Script('foo', 'www.example.com/script.js', Asset::FRONTEND);
+$script = new Script('foo', 'www.example.com/test-script.js', Asset::FRONTEND);
// overwrite location from constructor
$script->forLocation(Asset::BACKEND);
@@ -160,7 +160,7 @@ use Inpsyde\Assets\Script;
use Inpsyde\Assets\Style;
use Inpsyde\Assets\Asset;
-$script = new Script('foo', 'www.example.com/script.js', Asset::FRONTEND);
+$script = new Script('foo', 'www.example.com/test-script.js', Asset::FRONTEND);
$script->withDependencies('wp-elements', 'wp-core', 'wp-i18n');
$style = new Style('foo', 'www.example.com/style.css');
@@ -195,10 +195,10 @@ following:
use Inpsyde\Assets\Script;
use Inpsyde\Assets\Asset;
-$script = new Script('foo', 'www.example.com/script.js');
+$script = new Script('foo', 'www.example.com/test-script.js');
$script
->forLocation(Asset::FRONTEND)
- ->withFilePath('/path/to/script.js');
+ ->withFilePath('/path/to/test-script.js');
$script->dependencies(); // ["foo", "bar", "baz"]
$script->version(); // "1234567"
@@ -224,12 +224,12 @@ return [
use Inpsyde\Assets\Script;
use Inpsyde\Assets\Asset;
-$script = new Script('foo', 'www.example.com/script.js');
+$script = new Script('foo', 'www.example.com/test-script.js');
$script
->forLocation(Asset::FRONTEND)
->withVersion('1.0')
->withDependencies("some", "other", "dependencies")
- ->withFilePath('/path/to/script.js');
+ ->withFilePath('/path/to/test-script.js');
$script->dependencies(); // ["foo", "bar", "baz", "some", "other", "dependencies"]
$script->version(); // "1.0"
@@ -244,7 +244,7 @@ It is possible to change for an `Asset` the Handler like following:
use Inpsyde\Assets\Script;
use Inpsyde\Assets\Handler\ScriptHandler;
-$script = new Script('foo', 'www.example.com/script.js');
+$script = new Script('foo', 'www.example.com/test-script.js');
$script->useHandler(ScriptHandler::class);
```
@@ -259,7 +259,7 @@ Scripts are having the following filters available:
use Inpsyde\Assets\Script;
use Inpsyde\Assets\OutputFilter\AsyncScriptOutputFilter;
-$script = new Script('foo', 'www.example.com/script.js');
+$script = new Script('foo', 'www.example.com/test-script.js');
$script
->withFilters(AsyncScriptOutputFilter::class)
->useDeferFilter() // shortcut
@@ -299,7 +299,7 @@ Scripts can have localized data via `wp_localize_script()`, which can be added l
withLocalize('foo', ['multiple values'])
->withLocalize('bar', static function(): string {
@@ -315,7 +315,7 @@ Scripts can also have translation data via `wp_set_script_translations()`. This
withTranslation('domain', '/path/to/json/file.json');
```
@@ -327,7 +327,7 @@ To enqueue a script in header or footer - default is "footer" - we have followin
isInFooter()
->isInHeader();
@@ -341,7 +341,7 @@ To add inline scripts via `wp_add_inline_script()` to your `Script`, you can use
appendInlineScript('var foo = "bar";')
->prependInlineScript('var baz = "bam"');
@@ -389,8 +389,8 @@ Styles and Script can be wrapped into Conditional comments. To do so, you can us
use Inpsyde\Assets\Script;
use Inpsyde\Assets\Style;
-$script = new Script('foo', 'www.example.com/script.js');
-$script->withCondition('gt IE 9'); //
+$script = new Script('foo', 'www.example.com/test-script.js');
+$script->withCondition('gt IE 9'); //
$style = new Style('foo', 'www.example.com/style.css');
$style->withCondition('lt IE 9'); //
@@ -405,7 +405,7 @@ Allows you to set additional attributes to your `script`- or `link`-tag like fol
use Inpsyde\Assets\Style;
use Inpsyde\Assets\Script;
-$script = new Script('my-handle', 'script.js');
+$script = new Script('my-handle', 'test-script.js');
$script->withAttributes(
[
'async' => true,
@@ -413,7 +413,7 @@ $script->withAttributes(
'nonce' => wp_create_nonce()
]
);
-//
+//
$style = new Style('my-handle', 'style.css');
@@ -432,6 +432,6 @@ Existing attributes like "src" or "id" are not overwriteable. The `Inpsyde\Asset
withAttributes(['src' => 'another-script.js']); // Will not overwrite "script.js"
+$script = new Script('my-handle', 'test-script.js');
+$script->withAttributes(['src' => 'another-test-script.js']); // Will not overwrite "test-script.js"
```
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 788483f..0b04148 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -20,7 +20,7 @@ add_action(
AssetManager::ACTION_SETUP,
function(AssetManager $assetManager) {
$assetManager->register(
- new Script('foo', 'www.example.com/script.js'),
+ new Script('foo', 'www.example.com/test-script.js'),
new Style('foo', 'www.example.com/style.css')
);
}
diff --git a/docs/helpers.md b/docs/helpers.md
index 45ccee1..22253ad 100644
--- a/docs/helpers.md
+++ b/docs/helpers.md
@@ -21,10 +21,10 @@ The function `Inpsyde\Assets\assetSuffix` allows to automatically suffix the giv
use function Inpsyde\Assets\withAssetSuffix;
-$fileName = withAssetSuffix('my-script.js');
+$fileName = withAssetSuffix('my-test-script.js');
// if SCRIPT_DEBUG === false -> my-script.min.js
-// if SCRIPT_DEBUG === true -> my-script.js
+// if SCRIPT_DEBUG === true -> my-test-script.js
```
diff --git a/docs/loaders.md b/docs/loaders.md
index dc238c6..0face6a 100644
--- a/docs/loaders.md
+++ b/docs/loaders.md
@@ -23,7 +23,7 @@ The [webpack-manifest-plugin](https://www.npmjs.com/package/webpack-manifest-plu
**manifest.json**
```json
{
- "script.js": "/public/path/script.23dafsf2138d.js",
+ "test-script.js": "/public/path/script.23dafsf2138d.js",
"style.css": "style.23dafsf2138d.css",
"sub-folder/style.css": ""
}
diff --git a/docs/output-filter.md b/docs/output-filter.md
index 63e20e6..4e4462f 100644
--- a/docs/output-filter.md
+++ b/docs/output-filter.md
@@ -25,7 +25,7 @@ use Inpsyde\Assets\Asset;
use Inpsyde\Assets\Script;
use Inpsyde\Assets\OutputFilter\AsyncScriptOutputFilter;
-$script = new Script('my-handle', 'script.js', Asset::FRONTEND);
+$script = new Script('my-handle', 'test-script.js', Asset::FRONTEND);
$script = $script->withFilters(AsyncScriptOutputFilter::class);
```
@@ -80,6 +80,6 @@ $customFilter = function( string $html, Asset $asset ): string
return $html;
};
-$script = new Script('my-handle', 'script.js', Asset::FRONTEND);
+$script = new Script('my-handle', 'test-script.js', Asset::FRONTEND);
$script = $script->withFilters($customFilter);
```
diff --git a/src/AssetManager.php b/src/AssetManager.php
index 4841dd6..be4b00b 100644
--- a/src/AssetManager.php
+++ b/src/AssetManager.php
@@ -13,6 +13,7 @@
namespace Inpsyde\Assets;
+use Inpsyde\Assets\Caching\IgnoreCacheHandler;
use Inpsyde\Assets\Handler\AssetHandler;
use Inpsyde\Assets\Handler\OutputFilterAwareAssetHandler;
use Inpsyde\Assets\Handler\ScriptHandler;
@@ -51,6 +52,10 @@ final class AssetManager
* @var bool
*/
private $setupDone = false;
+ /**
+ * @var IgnoreCacheHandler
+ */
+ private $ignoreCacheHandler;
/**
* @param AssetHookResolver|null $hookResolver
@@ -59,6 +64,7 @@ public function __construct(AssetHookResolver $hookResolver = null)
{
$this->hookResolver = $hookResolver ?? new AssetHookResolver();
$this->assets = new \SplObjectStorage();
+ $this->ignoreCacheHandler = new IgnoreCacheHandler();
}
/**
@@ -317,4 +323,8 @@ private function ensureSetup(): void
$this->useDefaultHandlers();
do_action(self::ACTION_SETUP, $this);
}
+
+ public function ignoreCache(){
+ $this->ignoreCacheHandler->execute($this);
+ }
}
diff --git a/src/BaseAsset.php b/src/BaseAsset.php
index 01a8e50..84b34cb 100644
--- a/src/BaseAsset.php
+++ b/src/BaseAsset.php
@@ -13,6 +13,7 @@
namespace Inpsyde\Assets;
+use Inpsyde\Assets\Caching\IgnoreCacheHandler;
use Inpsyde\Assets\Handler\AssetHandler;
use Inpsyde\Assets\Util\AssetPathResolver;
use Inpsyde\Assets\OutputFilter\AssetOutputFilter;
diff --git a/src/Caching/IgnoreCacheHandler.php b/src/Caching/IgnoreCacheHandler.php
new file mode 100644
index 0000000..6f77b70
--- /dev/null
+++ b/src/Caching/IgnoreCacheHandler.php
@@ -0,0 +1,49 @@
+assets();
+
+ $assetHandles = [
+ Script::class => [],
+ Style::class => []
+ ];
+
+ foreach($assets as $assetKey => $assetType){
+ foreach($assetType as $asset){
+ $assetHandles[$assetKey][] = $asset->handle();
+ }
+ }
+
+ foreach($handlers as $ignorePluginHandler){
+ if($ignorePluginHandler->isInstalled()){
+ $ignorePluginHandler->apply($assetHandles);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Caching/IgnorePluginCacheInterface.php b/src/Caching/IgnorePluginCacheInterface.php
new file mode 100644
index 0000000..554b23a
--- /dev/null
+++ b/src/Caching/IgnorePluginCacheInterface.php
@@ -0,0 +1,19 @@
+