Hi, i have a problem with asset functions in Acorn.
I use this docs: Acorn 2.x: Assets Management | Roots Documentation
And this is my code:
public function generateCriticalCSS(): void
{
$asset = \Roots\asset('speed.css');
$critical_content = $asset->contents();
$style = "<style>{$critical_content}</style>";
echo $style;
}
But it doesnt work. So i copy one line of this code to setup.php
$asset = \Roots\asset('speed.css');
Fatal error : Uncaught Error: Call to undefined function app()
in /app/wp/wp-content/themes/bibabo/vendor/roots/acorn/src/Roots/helpers.php on line 20
asset() works fine some time ago, but yesterday i upgrade my composer and js libraries and now its doesnt work
package.json
"devDependencies": {
"@roots/bud": "^6.2.0",
"@roots/bud-imagemin": "^6.2.0",
"@roots/bud-postcss": "^6.2.0",
"@roots/bud-sass": "^6.2.0",
"@roots/bud-tailwindcss": "^6.2.0",
"@roots/sage": "^6.2.0",
"@tailwindcss/typography": "^0.5.2",
"prettier": "2.7.1",
"prettier-plugin-tailwindcss": "^0.1.11",
"tailwindcss-fluid": "^0.2.0",
"tailwindcss-fluid-spacing": "^0.4.0"
},
"volta": {
"node": "16.15.1",
"npm": "8.3.1"
},
"dependencies": {
"@alpinejs/intersect": "^3.10.2",
"alpinejs": "^3.10.2",
"glightbox": "^3.2.0",
"moment": "^2.29.3",
"moment-timezone": "^0.5.34",
"swiper": "^8.2.4",
"tailwind-hamburgers": "^1.2.2",
"tailwindcss-fluid-type": "^1.3.3"
}
composer.json
"require": {
"php": "^7.4|^8.1",
"advanced-custom-fields/advanced-custom-fields-pro": "~5.12.2",
"log1x/acf-composer": "^2.0",
"log1x/sage-directives": "^1.1",
"log1x/sage-svg": "^1.1",
"phpunit/phpunit": "^9.5",
"roots/acorn": "^2.0",
"wpackagist-plugin/acf-extended": "^0.8.8.7"
},