Verified Commit 6f5a57c3 authored by Erick Hitter's avatar Erick Hitter
Browse files

Improve utility added in f3471506 to allow for selecting specific timestamps

parent 8a732238
......@@ -7,13 +7,26 @@ namespace WP_Cron_Control_Revisited;
*
* Also removes superfluous, non-event data that Core stores in the option
*/
function collapse_events_array( $events ) {
function collapse_events_array( $events, $timestamp = null ) {
$collapsed_events = array();
// Ensure an event is always returned
if ( ! is_array( $events ) ) {
return $collapsed_events;
}
// Allow filtering to only events with a given timestamp
if ( is_numeric( $timestamp ) ) {
if ( isset( $events[ $timestamp ] ) ) {
$_events = $events[ $timestamp ];
$events = array( $timestamp => $_events, );
unset( $_events );
} else {
return $collapsed_events;
}
}
// Collapse whatever events we have into an easier format to deal with
foreach ( $events as $timestamp => $timestamp_events ) {
// Skip non-event data that Core includes in the option
if ( ! is_numeric( $timestamp ) ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment