1
0
Files
re_capitulating_queer/site/plugins/my-helper/index.php
2025-03-26 13:23:40 +01:00

43 lines
1.1 KiB
PHP

<?php
function colorToStr(string $color): string {
switch ($color) {
case "":
case "#f1edeb": return "white";
case "#ff00ff": return "pink";
case "#48bd8d": return "green";
case "#8200ff": return "lila";
case "#ff6700": return "orange";
case "#000000": return "black";
}
}
function bg(string $bgColor, string $gridColor): string {
if ($gridColor == "") $gridColor = "#8200ff";
$bg = 'bg-' . colorToStr($bgColor) . '-' . colorToStr($gridColor);
remember($bg);
return $bg;
}
function remember(string $value): string {
static $oldValue = "bg-white-lila";
$copy = $oldValue;
$oldValue = $value;
return $copy;
}
function randomBg(): string {
static $colors = ["#f1edeb", "#ff00ff", "#48bd8d", "#8200ff", "#ff6700"];
$a = array_rand($colors, 2);
return bg($colors[$a[0]], $colors[$a[1]]);
}
Kirby::plugin('cache/buster', [
'components' => [
'css' => function ($kirby, $url, $options) {
$hash = md5_file($url);
return "$url?$hash";
}
]
]);