Skip to content

Commit 2b05f49

Browse files
committed
Add version info to css hrefs
1 parent e834e62 commit 2b05f49

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

etc/config.sample.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"bnetdocs": {
3+
"asset_versioning": true,
34
"btc_donate_address": "",
45
"campaigns": {
56
"battleforthenet": "",

src/templates/header.inc.phtml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace BNETDocs\Templates;
55
use \BNETDocs\Libraries\Authentication;
66
use \BNETDocs\Libraries\Logger;
77
use \BNETDocs\Libraries\User;
8+
use \BNETDocs\Libraries\VersionInfo;
89

910
use \CarlBennett\MVC\Libraries\Common;
1011

@@ -18,6 +19,14 @@ if ( isset( Authentication::$user )) {
1819
$_header_staff = null;
1920
}
2021

22+
if ( Common::$config->bnetdocs->asset_versioning ) {
23+
if ( !is_null( VersionInfo::$version->bnetdocs )) {
24+
$_unique_css = '?v=' . VersionInfo::$version->bnetdocs[1];
25+
} else {
26+
$_unique_css = '?v=' . date('YmdHis');
27+
}
28+
}
29+
2130
$_campaign_battleforthenet = (
2231
!empty( Common::$config->bnetdocs->campaigns->battleforthenet ) ?
2332
'<script type="text/javascript" src="' .
@@ -44,13 +53,13 @@ $_campaign_vultr = (
4453
<?php } ?>
4554
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
4655
<?php if (Common::$config->bnetdocs->mobile_site_enabled) { ?>
47-
<link rel="stylesheet" href="<?php echo Common::relativeUrlToAbsolute("/a/main.css"); ?>" type="text/css" media="(min-width:1000px)"/>
48-
<link rel="stylesheet" href="<?php echo Common::relativeUrlToAbsolute("/a/main-mobile.css"); ?>" type="text/css" media="(max-width:999px)"/>
56+
<link rel="stylesheet" href="<?php echo Common::relativeUrlToAbsolute('/a/main.css' . $_unique_css); ?>" type="text/css" media="(min-width:1000px)"/>
57+
<link rel="stylesheet" href="<?php echo Common::relativeUrlToAbsolute('/a/main-mobile.css' . $_unique_css); ?>" type="text/css" media="(max-width:999px)"/>
4958
<?php } else { ?>
50-
<link rel="stylesheet" href="<?php echo Common::relativeUrlToAbsolute("/a/main.css"); ?>" type="text/css" media="all"/>
59+
<link rel="stylesheet" href="<?php echo Common::relativeUrlToAbsolute('/a/main.css' . $_unique_css); ?>" type="text/css" media="all"/>
5160
<?php }
5261
foreach ($this->additional_css as $path) { ?>
53-
<link rel="stylesheet" type="text/css" href="<?php echo Common::relativeUrlToAbsolute($path); ?>" media="all"/>
62+
<link rel="stylesheet" type="text/css" href="<?php echo Common::relativeUrlToAbsolute($path . $_unique_css); ?>" media="all"/>
5463
<?php } ?>
5564
<link rel="icon" href="<?php echo Common::relativeUrlToAbsolute("/a/VSZX0bJ.png"); ?>" type="image/png" sizes="156x174"/>
5665
<link rel="stylesheet" type="text/css" href="<?php echo Common::relativeUrlToAbsolute("/a/font/SourceSansPro-Regular-201508251844.css"); ?>"/>

0 commit comments

Comments
 (0)