forked from coryetzkorn/php-store-hours
/
index.php
72 lines (61 loc) · 2.02 KB
/
index.php
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<head>
<title>PHP Store Hours</title>
<style type="text/css">
body {
font-family: 'Helvetica Neue', arial;
text-align: center;
}
</style>
</head>
<body>
<h1>Gadgets Inc.</h1>
<h2>Store Hours</h2>
<?php
// REQUIRED
// Set your default time zone (listed here: http://php.net/manual/en/timezones.php)
date_default_timezone_set('America/New_York');
// Include the store hours class
require('StoreHours.class.php');
// REQUIRED
// Define daily open hours
// Must be in 24-hour format, separated by dash
// If closed for the day, leave blank (ex. sunday)
// If open multiple times in one day, enter time ranges separated by a comma
$hours = array(
'mon' => array('11:00-20:30'),
'tue' => array('11:00-13:00', '18:00-20:30'),
'wed' => array('11:00-20:30'),
'thu' => array('11:00-1:30'), // Open late
'fri' => array('11:00-20:30'),
'sat' => array('11:00-20:00'),
'sun' => array('') // Closed all day
);
// OPTIONAL
// Add exceptions (great for holidays etc.)
// MUST be in format month/day
// Do not include the year if the exception repeats annually
$exceptions = array(
'2/24' => array('11:00-18:00'),
'10/18' => array('11:00-16:00', '18:00-20:30')
);
// OPTIONAL
// Place HTML for output below. This is what will show in the browser.
// Use {%hours%} shortcode to add dynamic times to your open or closed message.
$template = array(
'open' => "<h3>Yes, we're open! Today's hours are {%hours%}.</h3>",
'closed' => "<h3>Sorry, we're closed. Today's hours are {%hours%}.</h3>",
'closed_all_day' => "<h3>Sorry, we're closed today.</h3>",
'separator' => " - ",
'join' => " and ",
'format' => "g:ia", // options listed here: http://php.net/manual/en/function.date.php
'hours' => "{%open%}{%separator%}{%closed%}"
);
// Instantiate class and call render method to output content
$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->render();
?>
</body>
</html>