-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathmix.php
41 lines (33 loc) · 1004 Bytes
/
mix.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Lavarel mix WordPress function
*
* @link https://github.com/mindkomm/theme-lib-mix/blob/master/mix.php
*/
namespace Jacoby\Intervention;
/**
* Mix
*
* @return string
*/
function mix($path, $manifest_directory = 'assets')
{
// path to `mix-manifest.json`
$manifest_path = INTERVENTION_DIR . '/' . $manifest_directory . '/mix-manifest.json';
// escape if `mix-manifest.json` is not found
if (!file_exists($manifest_path)) {
return;
}
// get manifest json file
$manifest = json_decode(file_get_contents($manifest_path), true);
// remove manifest directory from path
$path = str_replace($manifest_directory, '', $path);
// ensure there is a leading slash
$path = '/' . ltrim($path, '/');
// get file url from `mix-manifest.json`
$path = $manifest[$path];
// sanitise any leading slash
$path = ltrim($path, '/');
// return
return plugin_dir_url(__FILE__) . trailingslashit($manifest_directory) . $path;
}