-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
97 lines (80 loc) · 3.11 KB
/
functions.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// Add featured images support
add_theme_support('post-thumbnails');
set_post_thumbnail_size(918, 250);
// Register Menu(s)
if (function_exists('register_nav_menu')) {
register_nav_menu('primary_navigation', 'Primary Navigation');
}
// Widgetize Sidebar
if (function_exists('register_sidebar')) {
register_sidebar(
array(
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>'
)
);
}
/**
* Calculates and returns a timestamp or formatted text for the next,
* first Friday of the month.
*
* This software is liscensed under the MIT License.
* More info available at https://github.com/PHX2600/FirstFriday
*
* @author Chris Kankiewicz (http://www.chriskankiewicz.com)
* @copyright 2011 Chris Kankiewicz
*/
class FirstFriday {
// Define application version
const VERSION = '1.1.0';
/**
* Main first Friday function. Calculates and returns a timestamp or
* formatted text for the next, first Friday of the month.
*
* @param boolean $formatted True = returns a formatted string. False = unix time stamp
* @param string $format PHP date format string. Default value = "F j, Y"
* @return string Formatted string of the next first Friday
* @access public
*/
public function firstFriday($formatted = true, $format = "F j, Y") {
if ($formatted == true) {
return $this->_firstFridayFormatted($format);
} else {
return $this->_firstFridayStamp();
}
}
/**
* Returns timestamp of the next first Friday
*
* @return string Unix timestamp of the next first Friday
* @access private
*/
private function _firstFridayStamp() {
// Calculate first Friday of this month
$thisFirstFriday = strtotime('first friday of this month');
if (date('d') > date('d', $thisFirstFriday)) {
// Calculate first Friday of next month
$nextFirstFriday = strtotime('first friday of next month');
$firstFriday = $nextFirstFriday;
} else {
// Set the next first Friday
$firstFriday = $thisFirstFriday;
}
// Return next first Friday timestamp
return $firstFriday;
}
/**
* Returns formatted string of the next first Friday
*
* @param $format PHP date format string
* @return string Formatted string of the next first Friday
* @access private
*/
private function _firstFridayFormatted($format) {
// Return formatted date
return date($format, $this->_firstFridayStamp());
}
}