\Granola\assetURL();

Accepting one parameter, \Granola\assetURL(); will build a url to a file that is processed with the build tools.

<img src="<?php echo \Granola\assetURL('images/example.png'); ?>">

Will result in

<img src="https://example.com/wp-content/themes/granola/assets/images/example.png">

\Granola\assetPath();

Accepting one parameter, \Granola\assetPath(); will build a path to a file that is processed with the build tools. This will return a full path to the file on disk.

$path = \Granola\assetPath('general/file.csv');

\Granola\assetContent();

Requiring one parameter, and accepting a secondary optional parameter, assetContent allows for importing the contents of a file. The first parameter is a path to the file (relative to the assets directory), and the second a string that defines the type of content being loaded.

In the event of the second parameter being set to json, the file will be run through json_decode before being returned.

$content = \Granola\assetContent('images/example.svg'); // This will return the code that makes up the SVG

$content = \Granola\assetContent('general/example.json', 'json'); // This will return the content of example.json after being passed through json_decode