Automattic\WP\Cron_Control\CLI\Events::format_events PHP Метод

format_events() приватный Метод

Format event data into something human-readable
private format_events ( $events )
    private function format_events($events)
    {
        $formatted_events = array();
        // Reformat events
        foreach ($events as $event) {
            $row = array('ID' => $event->ID, 'action' => '', 'instance' => '', 'next_run_gmt' => date(TIME_FORMAT, strtotime($event->post_date_gmt)), 'next_run_relative' => '', 'last_updated_gmt' => date(TIME_FORMAT, strtotime($event->post_modified_gmt)), 'recurrence' => __('Non-repeating', 'automattic-cron-control'), 'internal_event' => '', 'schedule_name' => __('n/a', 'automattic-cron-control'), 'event_args' => '');
            // Provide relative next run only for events that have yet to run
            if ($event->post_status === \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_STATUS_PENDING) {
                $row['next_run_relative'] = $this->calculate_interval(strtotime($event->post_date_gmt) - time());
            }
            // Most data serialized in the post
            $all_args = maybe_unserialize($event->post_content_filtered);
            if (is_array($all_args)) {
                // Action
                if (isset($all_args['action'])) {
                    $row['action'] = $all_args['action'];
                    $row['internal_event'] = \Automattic\WP\Cron_Control\is_internal_event($all_args['action']) ? __('true', 'automattic-cron-control') : '';
                }
                // Instance
                if (isset($all_args['instance'])) {
                    $row['instance'] = $all_args['instance'];
                }
                // Additional arguments
                if (isset($all_args['args'])) {
                    $args = $all_args['args'];
                    // Event arguments themselves
                    if (isset($args['args'])) {
                        $row['event_args'] = maybe_serialize($args['args']);
                    }
                    // Human-readable version of next run
                    if (isset($args['interval']) && $args['interval']) {
                        $row['recurrence'] = $this->calculate_interval($args['interval']);
                    }
                    // Named schedule
                    if (isset($args['schedule']) && $args['schedule']) {
                        $row['schedule_name'] = $args['schedule'];
                    }
                }
            }
            $formatted_events[] = $row;
        }
        return $formatted_events;
    }