answer(); } /** * Work out the answer. * * @return array */ private function answer(): array { $check = $this->guard( 'etn_manage_event' ); if ( $check ) { return $check; } try { $counts = $this->query->count_events(); return [ 'status' => 'ok', 'counts' => $counts, 'today' => current_time( 'Y-m-d' ), 'definitions' => [ 'all' => 'Every event that is not in the trash, drafts included.', 'published' => 'Live events.', 'upcoming' => 'Published, starting today or later.', 'ongoing' => 'Published, started on or before today and ending today or later.', 'past' => 'Published, ended before today. This is what people mean by expired.', 'no_date' => 'Published, but no start date is set, so it is in none of the groups above.', 'draft' => 'Saved but not published.', ], 'page' => $this->page( __( 'Events', 'aisentic' ), '/events' ), ]; } catch ( \Throwable $e ) { Log::error( 'Eventin_Count_Events_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Could not count events: ' . $e->getMessage() ]; } } }