File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,6 @@ public function get_referrers(\WP_REST_Request $request): \WP_REST_Response
215215 public function get_realtime_pageview_count (\WP_REST_Request $ request )
216216 {
217217 $ params = $ request ->get_query_params ();
218- $ since = isset ($ params ['since ' ]) ? strtotime ($ params ['since ' ]) : null ;
219- return get_realtime_pageview_count ($ since );
218+ return get_realtime_pageview_count ($ params ['since ' ] ?? null );
220219 }
221220}
Original file line number Diff line number Diff line change 88
99namespace KokoAnalytics ;
1010
11+ use ParagonIE \Sodium \Core \Curve25519 \Ge \P2 ;
1112use WP_Admin_Bar ;
1213use WP_Query ;
1314use WP_Post ;
@@ -133,17 +134,20 @@ function widgets_init()
133134}
134135
135136/**
136- * @param int|string $since Either an integer timestamp (in seconds since Unix epoch) or a relative time string that strtotime understands.
137+ * @param int|string|null $since Either an integer timestamp (in seconds since Unix epoch) or a relative time string that strtotime understands.
137138 * @return int
138139 */
139- function get_realtime_pageview_count ($ since = ' -5 minutes ' ): int
140+ function get_realtime_pageview_count ($ since = null ): int
140141{
141- if (is_numeric ($ since )) {
142+ if (is_numeric ($ since ) || is_int ( $ since ) ) {
142143 $ since = (int ) $ since ;
143- } else {
144+ } elseif ( is_string ( $ since )) {
144145 // $since is relative time string
145146 $ since = strtotime ($ since );
147+ } else {
148+ $ since = strtotime ('-5 minutes ' );
146149 }
150+
147151 $ counts = (array ) get_option ('koko_analytics_realtime_pageview_count ' , []);
148152 $ sum = 0 ;
149153 foreach ($ counts as $ timestamp => $ pageviews ) {
You can’t perform that action at this time.
0 commit comments