Upgrade to 3.1.3
This commit is contained in:
@@ -13,49 +13,6 @@ use Kirby\Toolkit\F;
|
||||
*/
|
||||
class PluginAssets
|
||||
{
|
||||
|
||||
/**
|
||||
* Concatenate all plugin js and css files into
|
||||
* a single file and copy them to /media/plugins/index.css or /media/plugins/index.js
|
||||
*
|
||||
* @param string $extension
|
||||
* @return string
|
||||
*/
|
||||
public static function index(string $extension): string
|
||||
{
|
||||
$kirby = App::instance();
|
||||
$cache = $kirby->root('media') . '/plugins/.index.' . $extension;
|
||||
$build = false;
|
||||
$modified = [0];
|
||||
$assets = [];
|
||||
|
||||
foreach ($kirby->plugins() as $plugin) {
|
||||
$file = $plugin->root() . '/index.' . $extension;
|
||||
|
||||
if (file_exists($file) === true) {
|
||||
$assets[] = $file;
|
||||
$modified[] = F::modified($file);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($assets)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file_exists($cache) === false || filemtime($cache) < max($modified)) {
|
||||
$dist = [];
|
||||
foreach ($assets as $asset) {
|
||||
$dist[] = file_get_contents($asset);
|
||||
}
|
||||
$dist = implode(PHP_EOL, $dist);
|
||||
F::write($cache, $dist);
|
||||
} else {
|
||||
$dist = file_get_contents($cache);
|
||||
}
|
||||
|
||||
return $dist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean old/deprecated assets on every resolve
|
||||
*
|
||||
@@ -105,6 +62,9 @@ class PluginAssets
|
||||
$target = $plugin->mediaRoot() . '/' . $filename;
|
||||
$url = $plugin->mediaUrl() . '/' . $filename;
|
||||
|
||||
// create the plugin directory first
|
||||
Dir::make($plugin->mediaRoot(), true);
|
||||
|
||||
if (F::link($source, $target, 'symlink') === true) {
|
||||
return Response::redirect($url);
|
||||
}
|
||||
|
Reference in New Issue
Block a user