$widget ) + $wp_meta_boxes['dashboard']['normal']['core']; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Documented way to reorder dashboard widgets. } } /** * Widget content. */ public static function render() { Inventory::maybe_detect_external(); $settings = Settings::all(); $color = $settings['brand_color']; $data = self::data(); ?>
Log::TYPE_MANUAL, 'from' => $month_start, 'per_page' => 0, ) ); $updates = array_filter( Log::query( array( 'type' => Log::TYPE_UPDATE, 'from' => $month_start, 'per_page' => 0, ) ), static function ( $entry ) { return isset( $entry->details['kind'] ) && in_array( $entry->details['kind'], Reporter::CLIENT_UPDATE_KINDS, true ); } ); $latest = Log::query( array( 'types' => array( Log::TYPE_UPDATE, Log::TYPE_CHECK, Log::TYPE_MANUAL, Log::TYPE_PERFORMANCE ), 'per_page' => 1, ) ); $last_check = self::last_site_check(); $report_url = ''; if ( Public_Report::is_enabled() ) { $sent = Public_Report::sent_reports( 1 ); $report_url = $sent ? Public_Report::url( $sent[0]['from'], $sent[0]['to'] ) : ''; } elseif ( Plugin::user_can_manage() ) { $report_url = admin_url( 'admin.php?page=' . Admin\Admin::REPORT_SLUG ); } return array( 'all_ok' => ( ! $last_check || Log::STATUS_ERROR !== $last_check->status ) && Tech_Status::OK === Tech_Status::worst( Tech_Status::get()['items'] ), 'last_activity' => $latest ? strtotime( $latest[0]->created_at . ' UTC' ) : 0, 'updates' => count( $updates ), 'checks' => Log::count( array( 'type' => Log::TYPE_CHECK, 'from' => $month_start, ) ), 'minutes' => array_sum( wp_list_pluck( $tasks, 'minutes' ) ), 'report_url' => $report_url, ); } /** * Latest page check (not technical status entries). * * @return object|null */ private static function last_site_check() { foreach ( Log::query( array( 'type' => Log::TYPE_CHECK, 'per_page' => 10, ) ) as $entry ) { if ( 'technical' !== $entry->category ) { return $entry; } } return null; } }