PluginProbe
Stream – Activity Log & Audit Trail / 3.9.0
Stream – Activity Log & Audit Trail v3.9.0
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-date-interval.php +32 -15 3.2.13.9.0 View file →
@@ -1,14 +1,22 @@
1 1 <?php
2 +/**
3 + * Calculate date intervals for a specific timezone.
4 + *
5 + * @package WP_Stream
6 + */
7 +
2 8 namespace WP_Stream;
3 9
4 -// Load Carbon to Handle dates much easier
10 +// Load Carbon to Handle dates much easier.
5 11 if ( ! class_exists( 'Carbon\Carbon' ) ) {
6 12 require_once wp_stream_get_instance()->locations['inc_dir'] . 'lib/Carbon.php';
7 13 }
8 -
9 14 use Carbon\Carbon;
10 15
16 +/**
17 + * Class - Date_Interval
18 + */
11 19 class Date_Interval {
12 20 /**
13 21 * Contains an array of all available intervals
14 22 *
@@ -19,14 +27,17 @@
19 27 /**
20 28 * Class constructor
21 29 */
22 30 public function __construct() {
23 - // Get all default intervals
31 + // Get all default intervals.
24 32 $this->intervals = $this->get_predefined_intervals();
25 33 }
26 34
27 35 /**
28 - * @return mixed|void
36 + * Returns date interval data based upon "Timezone" site setting.
37 + *
38 + * @todo add better inline comments
39 + * @return mixed
29 40 */
30 41 public function get_predefined_intervals() {
31 42 $timezone = get_option( 'timezone_string' );
32 43
@@ -43,64 +54,70 @@
43 54
44 55 return apply_filters(
45 56 'wp_stream_predefined_date_intervals',
46 57 array(
47 - 'today' => array(
58 + 'today' => array(
48 59 'label' => esc_html__( 'Today', 'stream' ),
49 60 'start' => Carbon::today( $timezone )->startOfDay(),
50 61 'end' => Carbon::today( $timezone )->endOfDay(),
51 62 ),
52 - 'yesterday' => array(
63 + 'yesterday' => array(
53 64 'label' => esc_html__( 'Yesterday', 'stream' ),
54 65 'start' => Carbon::today( $timezone )->startOfDay()->subDay(),
55 66 'end' => Carbon::today( $timezone )->startOfDay()->subSecond(),
56 67 ),
57 - 'last-7-days' => array(
68 + 'last-7-days' => array(
69 + /* translators: %d: number of days (e.g. "7") */
58 70 'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 7 ),
59 71 'start' => Carbon::today( $timezone )->subDays( 7 ),
60 72 'end' => Carbon::today( $timezone ),
61 73 ),
62 - 'last-14-days' => array(
74 + 'last-14-days' => array(
75 + /* translators: %d: number of days (e.g. "7") */
63 76 'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 14 ),
64 77 'start' => Carbon::today( $timezone )->subDays( 14 ),
65 78 'end' => Carbon::today( $timezone ),
66 79 ),
67 - 'last-30-days' => array(
80 + 'last-30-days' => array(
81 + /* translators: %d: number of days (e.g. "7") */
68 82 'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 30 ),
69 83 'start' => Carbon::today( $timezone )->subDays( 30 ),
70 84 'end' => Carbon::today( $timezone ),
71 85 ),
72 - 'this-month' => array(
86 + 'this-month' => array(
73 87 'label' => esc_html__( 'This Month', 'stream' ),
74 88 'start' => Carbon::today( $timezone )->startOfMonth(),
75 89 'end' => Carbon::today( $timezone )->endOfMonth(),
76 90 ),
77 - 'last-month' => array(
91 + 'last-month' => array(
78 92 'label' => esc_html__( 'Last Month', 'stream' ),
79 93 'start' => Carbon::today( $timezone )->startOfMonth()->subMonth(),
80 94 'end' => Carbon::today( $timezone )->startOfMonth()->subSecond(),
81 95 ),
82 - 'last-3-months' => array(
96 + 'last-3-months' => array(
97 + /* translators: %d: number of months (e.g. "3") */
83 98 'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 3 ),
84 99 'start' => Carbon::today( $timezone )->subMonths( 3 ),
85 100 'end' => Carbon::today( $timezone ),
86 101 ),
87 - 'last-6-months' => array(
102 + 'last-6-months' => array(
103 + /* translators: %d: number of months (e.g. "3") */
88 104 'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 6 ),
89 105 'start' => Carbon::today( $timezone )->subMonths( 6 ),
90 106 'end' => Carbon::today( $timezone ),
91 107 ),
92 108 'last-12-months' => array(
109 + /* translators: %d: number of months (e.g. "3") */
93 110 'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 12 ),
94 111 'start' => Carbon::today( $timezone )->subMonths( 12 ),
95 112 'end' => Carbon::today( $timezone ),
96 113 ),
97 - 'this-year' => array(
114 + 'this-year' => array(
98 115 'label' => esc_html__( 'This Year', 'stream' ),
99 116 'start' => Carbon::today( $timezone )->startOfYear(),
100 117 'end' => Carbon::today( $timezone )->endOfYear(),
101 118 ),
102 - 'last-year' => array(
119 + 'last-year' => array(
103 120 'label' => esc_html__( 'Last Year', 'stream' ),
104 121 'start' => Carbon::today( $timezone )->startOfYear()->subYear(),
105 122 'end' => Carbon::today( $timezone )->startOfYear()->subSecond(),
106 123 ),