Skip to content

Commit

Permalink
Basic ignore cache feature with the support for two plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
inpsyde-maticluznar committed Jul 23, 2024
1 parent d747f63 commit ec47757
Show file tree
Hide file tree
Showing 21 changed files with 355 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
15 changes: 15 additions & 0 deletions .idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 79 additions & 48 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions assets-plugin/assets-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
);
7 changes: 7 additions & 0 deletions assets-plugin/resources/test-script-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
document.addEventListener('DOMContentLoaded', function(){
sayHelloAgain();
})

function sayHelloAgain(){
console.log('HELLO AGAIN!');
}
7 changes: 7 additions & 0 deletions assets-plugin/resources/test-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
document.addEventListener('DOMContentLoaded', function(){
sayHello();
})

function sayHello(){
console.log('HELLO!');
}
3 changes: 3 additions & 0 deletions assets-plugin/resources/test-style-2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body{
opacity: 0.99;
}
3 changes: 3 additions & 0 deletions assets-plugin/resources/test-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body{
background:#f0f0f0 !important;
}
Loading

0 comments on commit ec47757

Please sign in to comment.