Verified Commit f3471506 authored by Erick Hitter's avatar Erick Hitter
Browse files

Introduce utility method to replace many of the nested `foreach()` patterns...

Introduce utility method to replace many of the nested `foreach()` patterns needed to extract event data from the format Core uses
parent 5db6f5fd
<?php
namespace WP_Cron_Control_Revisited;
/**
* Produce a simplified version of the cron events array
*
* Also removes superfluous, non-event data that Core stores in the option
*/
function collapse_events_array( $events ) {
$collapsed_events = array();
if ( ! is_array( $events ) ) {
return $collapsed_events;
}
foreach ( $events as $timestamp => $timestamp_events ) {
// Skip non-event data that Core includes in the option
if ( ! is_numeric( $timestamp ) ) {
continue;
}
foreach ( $timestamp_events as $action => $action_instances ) {
foreach ( $action_instances as $instance => $instance_args ) {
$collapsed_events[] = array(
'timestamp' => $timestamp,
'action' => $action,
'instance' => $instance,
'args' => $instance_args,
);
}
}
}
return $collapsed_events;
}
......@@ -12,6 +12,7 @@ namespace WP_Cron_Control_Revisited;
// Load basics needed to instantiate plugin
require __DIR__ . '/includes/constants.php';
require __DIR__ . '/includes/utils.php';
require __DIR__ . '/includes/abstract-class-singleton.php';
require __DIR__ . '/includes/class-lock.php';
......
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