Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.03 KB

helpers.md

File metadata and controls

43 lines (29 loc) · 1.03 KB
nav_order
6

Helpers

{: .no_toc }

Table of contents

{: .no_toc .text-delta }

  1. TOC {:toc}

The inpsyde/assets-Package comes with some useful helper functions.

Asset Suffix

The function Inpsyde\Assets\assetSuffix allows to automatically suffix the given Asset with .min if SCRIPT_DEBUG === false:

<?php

use function Inpsyde\Assets\withAssetSuffix;

$fileName = withAssetSuffix('my-script.js');

// if SCRIPT_DEBUG === false -> my-script.min.js
// if SCRIPT_DEBUG === true -> my-script.js

Symlink an Asset-folder

Sometimes your Assets will not be inside the web-root, like Composer packages which are normally published outside of web-root. Therefor you can use a simple helper Inpsyde\Assets\symlinkedAssetFolder which allows you to move your asset-folder inside the web-root:

<?php

use function Inpsyde\Assets\symlinkedAssetFolder;

$assetDirUrl = symlinkedAssetFolder('/full/path/to/assets/', 'my-package');
// will return: https://www.example.com/wp-content/~inpsyde-assets/my-package/