45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
$lang = isset($_SESSION['lang']) ? $_SESSION['lang'] : 'en';
|
|
$version = $this->getVersion();
|
|
|
|
function getUrl($fileName) {
|
|
global $version;
|
|
|
|
if (file_exists($fileName))
|
|
$fileVersion = strftime('%G%m%d%H%M%S', filemtime($fileName));
|
|
else
|
|
$fileVersion = $version;
|
|
|
|
return "$fileName?$fileVersion";
|
|
}
|
|
|
|
function js($fileName) {
|
|
return '<script type="text/javascript" src="'. getUrl("$fileName.js") .'"></script>'."\n";
|
|
}
|
|
|
|
function css($fileName) {
|
|
return '<link rel="stylesheet" type="text/css" href="'. getUrl("$fileName.css") .'"/>'."\n";
|
|
}
|
|
|
|
function getWebpackAssets() {
|
|
$wpConfig = json_decode(file_get_contents('webpack.config.json'));
|
|
$buildDir = $wpConfig->buildDir;
|
|
$serverPath = '';
|
|
|
|
if (_DEV_MODE) {
|
|
$devServerPort = $wpConfig->devServerPort;
|
|
$host = $_SERVER['SERVER_NAME'];
|
|
$serverPath = "http://$host:$devServerPort/";
|
|
}
|
|
|
|
$wpAssets = json_decode(file_get_contents("$buildDir/webpack-assets.json"));
|
|
$jsFiles = [];
|
|
|
|
foreach ($wpAssets as $name => $asset)
|
|
if (!empty($name) && property_exists($asset, 'js'))
|
|
$jsFiles[] = $serverPath . $asset->js;
|
|
|
|
return $jsFiles;
|
|
}
|