%d%s
', $count > 0 && $heat !== '' ? ' is-' . esc_attr($heat) : '', esc_url($url), esc_attr($icon), (int) $count, esc_html($label), ); } public function render(): void { if (!self::connected()) { echo '

' . esc_html__('Change your site by asking, let visitors report bugs, and approve fixes right here. Two minutes to connect.', 'sarcio') . '

'; printf('

%s

', esc_url(self::page(ReviewPage::SLUG)), esc_html__('Set up Sarcio', 'sarcio')); return; } $summary = InboxSummary::get(); $kept = count(array_filter(KeptFixes::all(), static fn ($fix): bool => is_array($fix) && !empty($fix['enabled']))); $requests = Requests::pendingCount(); if ($summary === null) { echo '

' . esc_html__('Sarcio could not be reached just now; the counts below are from this site only.', 'sarcio') . '

'; $summary = ['awaitingSecondApproval' => 0, 'live' => 0, 'needsReview' => 0, 'noticed' => 0, 'triaging' => 0]; } echo '
'; self::tile(self::page(ReviewPage::SLUG), 'dashicons-yes-alt', (int) $summary['needsReview'], __('Fixes ready to check', 'sarcio'), 'hot'); self::tile(self::page(ReviewPage::SLUG), 'dashicons-groups', (int) $summary['awaitingSecondApproval'], __('Waiting for a second approval', 'sarcio'), 'warm'); self::tile(self::page(RequestsPage::SLUG), 'dashicons-format-chat', $requests, __('Requests to apply', 'sarcio'), 'warm'); self::tile(self::page(ReviewPage::SLUG), 'dashicons-search', (int) $summary['triaging'], __('Reports being looked at', 'sarcio')); self::tile(self::page(ReviewPage::LIVE_SLUG), 'dashicons-controls-play', (int) $summary['live'], __('Fixes live right now', 'sarcio')); self::tile(self::page(KeptFixesPage::SLUG), 'dashicons-lock', $kept, __('Fixes kept on this site', 'sarcio')); echo '
'; if ((int) $summary['needsReview'] + (int) $summary['awaitingSecondApproval'] + $requests === 0) { echo '

' . esc_html__('All caught up. Nothing is waiting for you.', 'sarcio') . '

'; } echo '
'; printf('%s', esc_url(self::page(ReviewPage::SLUG)), esc_html__('Open the Inbox', 'sarcio')); printf('%s', esc_url(self::assistantUrl()), esc_html__('Ask the assistant', 'sarcio')); echo '
'; } public function renderNoticed(): void { $summary = InboxSummary::get(); $workspace = Embed::workspaceUrl() ?? 'https://www.sarcio.io/app/'; if ($summary === null) { echo '

' . esc_html__('Sarcio could not be reached just now.', 'sarcio') . '

'; return; } if (!$summary['noticeEnabled']) { echo '

' . esc_html__('Sarcio can watch for what fails on your visitors’ pages (an error, a broken request) and open a report with a fix drafted when several of them hit the same thing, before anyone reports it. It is off for this site.', 'sarcio') . '

'; printf('

%s

', esc_url($workspace), esc_html__('Turn on Sarcio noticed', 'sarcio')); return; } echo '
'; printf('
%d%s
', (int) $summary['noticed'], esc_html__('reports opened by Sarcio, last 7 days', 'sarcio')); printf('
%d%s
', count($summary['signals']), esc_html__('failures seen by visitors', 'sarcio')); echo '
'; if ($summary['signals'] === []) { echo '

' . esc_html__('Nothing failed for your visitors this week.', 'sarcio') . '

'; return; } echo '
'; foreach ($summary['signals'] as $signal) { $where = $signal['kind'] === 'request' ? trim(($signal['method'] ?? '') . ' ' . $signal['sample'] . ($signal['status'] !== null ? ' → ' . $signal['status'] : '')) : $signal['sample']; printf( '
%s%s
', $signal['reported'] ? ' is-reported' : '', $signal['kind'] === 'request' ? 'dashicons-warning' : 'dashicons-editor-code', esc_html($where), esc_html(sprintf( /* translators: 1: the page path, 2: how many visitors, 3: "reported" or "watching". */ _n('on %1$s · %2$d visitor · %3$s', 'on %1$s · %2$d visitors · %3$s', $signal['count'], 'sarcio'), $signal['urlPath'], $signal['count'], $signal['reported'] ? __('a report is open', 'sarcio') : __('watching', 'sarcio'), )), ); } echo '
'; printf('

%s

', esc_url(self::page(ReviewPage::SLUG)), esc_html__('See the reports', 'sarcio')); } public function renderAssistant(): void { $recognised = Recognised::all(); $bridged = Recognised::bridged(); $updates = current_user_can('update_plugins') ? count(UpdateAbilities::pendingPlugins()) : 0; $pending = array_values(array_filter(Scheduled::list(), static fn (array $schedule): bool => $schedule['status'] === 'pending')); $recent = array_slice(array_values(array_filter(Journal::recent(), static fn (array $entry): bool => $entry['ability'] !== 'sarcio/changes-undo' && JournalAbilities::visible($entry))), 0, 3); echo ''; if ($pending !== []) { echo ''; } if ($recent !== []) { echo ''; } $report = Report::build(Report::previousMonth()); echo '
'; printf('%s', esc_url(self::assistantUrl()), esc_html__('Ask the assistant', 'sarcio')); printf('%s', esc_url(self::page(ReportPage::SLUG)), esc_html__('Monthly report', 'sarcio')); if ($report['counts']['changes'] + $report['counts']['kept'] > 0) { printf('

%s

', esc_html(sprintf( /* translators: 1: the month, 2: changes, 3: kept fixes. */ __('%1$s: %2$d changes made by asking, %3$d fixes kept.', 'sarcio'), $report['label'], $report['counts']['changes'], $report['counts']['kept'], ))); } echo '
'; } }