blob: 36a4c6f56c765a2353066b63b8a910a1995bb49d (
plain)
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
|
<?php
class Theme
{
public function dark()
{
return $darkTheme = $_COOKIE['darkTheme'] ?? null;
}
public function set($theme)
{
$time = time()+3600*24*365*10;
if ($theme === null) {
setcookie('darkTheme', 'on', $time, '/');
return $_COOKIE['darkTheme'] = 'on';
}
setcookie('darkTheme', null, $time, '/');
return $_COOKIE['darkTheme'] = null;
}
public function toggle()
{
$toggle = $_GET['toggle'] ?? null;
if ($toggle === 'theme') {
$theme = $this->set($this->dark());
}
}
}
|