GitLab
Products
Versions
Pages
Last sync
OLM updates
Last OLM sync
FormatMarkdown
(bool) (Plugin::settings()['gitlab_base_url'] && Plugin::settings()['gitlab_token']),
'counts' => self::counts(),
'last_sync' => get_option('kb_markdown_importer_last_sync', ''),
'last_changelog_sync' => ChangelogSync::lastSync(),
'last_error' => get_option('kb_markdown_importer_last_error', ''),
]);
}
public static function renderLogTable(array $logs): void
{
if (! $logs) {
echo '' . esc_html__('No logs yet.', 'kb-markdown-importer') . '
';
return;
}
echo '| Time | Level | Message |
';
foreach ($logs as $entry) {
printf(
'| %s | %s | %s |
',
esc_html((string) ($entry['time'] ?? '')),
esc_html((string) ($entry['level'] ?? 'INFO')),
esc_html((string) ($entry['message'] ?? ''))
);
}
echo '
';
}
private static function counts(): array
{
$pages = wp_count_posts('kb_doc_page');
$products = wp_count_terms(['taxonomy' => 'kb_product', 'hide_empty' => false]);
$versions = wp_count_terms(['taxonomy' => 'kb_version', 'hide_empty' => false]);
return [
'products' => is_wp_error($products) ? 0 : (int) $products,
'versions' => is_wp_error($versions) ? 0 : (int) $versions,
'pages' => (int) ($pages->publish ?? 0),
];
}
}