blob: f146a7c66a0d5d3973e2f5afde30314c735cfe7a (
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
32
33
34
35
36
37
38
39
40
41
42
|
<?php
class Theme
{
public function color()
{
return $theme = $_COOKIE['theme'] ?? null;
}
public function option()
{
return $theme = $_GET['theme'] ?? null;
}
public function set($theme)
{
$time = time() + 3600 * 24 * 365 * 10;
if ($theme === null) {
setcookie('theme', 'dark', $time, '/');
return $_COOKIE['theme'] = 'dark';
}
setcookie('theme', $theme, $time, '/');
return $_COOKIE['theme'] = $theme;
}
public function toggle()
{
$theme = $this->option();
if ($theme === 'dark') {
$theme = $this->set($this->option());
return;
}
if ($theme === 'light') {
$theme = $this->set($this->option());
}
}
}
|