websiteProvider = new ContaiWebsiteProvider();
$this->service = new ContaiSearchConsoleService(null, $this->websiteProvider);
$this->statusChecker = new ContaiWebsiteStatusChecker();
}
public function render(): void
{
$this->enqueueAssets();
if (!contai_has_active_license()) {
$this->renderLicenseRequired();
return;
}
$status = $this->websiteProvider->initializeWebsiteStatus();
?>
renderMessage(); ?>
renderContent($status); ?>
websiteProvider->getUserProfile();
if (!$userProfile) {
$this->renderUserNotConfigured();
return;
}
if ($status['status'] === 'error') {
$this->renderError($status['message'] ?? 'Unknown error');
return;
}
if ($status['status'] === 'not_found') {
$this->renderWebsiteNotFound();
return;
}
$config = $status['config'];
if ($this->statusChecker->isVerified($config)) {
$verifiedSection = new ContaiSearchConsoleVerifiedSection($config);
$verifiedSection->render();
// Only a verified property has anything for Google to report on
// (SCP-04) — same gate as the section above, not a second one.
$performanceSection = new ContaiSearchConsolePerformanceSection();
$performanceSection->render();
$this->enqueuePerformanceAssets();
return;
}
$hasSearchConsoleData = !empty($config['file_name']);
if (!$hasSearchConsoleData) {
$addSection = new ContaiSearchConsoleAddWebsiteSection(
$this->websiteProvider->getSiteUrl(),
$this->websiteProvider->getSitemapUrls()
);
$addSection->render();
return;
}
$verificationSection = new ContaiSearchConsoleVerificationSection(
$config,
$this->service->verificationFileExists()
);
$verificationSection->render();
}
private function renderWebsiteNotFound(): void
{
?>
rest_url('contai/v1/search-console/performance'),
'sitemapsUrl' => rest_url('contai/v1/search-console/sitemaps'),
'nonce' => wp_create_nonce('wp_rest'),
'i18n' => [
'loading' => __('Loading performance data…', '1platform-content-ai'),
'error' => __('Could not load performance data.', '1platform-content-ai'),
'quota' => __('Too many requests right now. Try again in a few minutes.', '1platform-content-ai'),
'notVerified' => __('This website is not verified in Search Console yet.', '1platform-content-ai'),
'colIndexed' => __('Indexed / read', '1platform-content-ai'),
'colIssues' => __('Issues', '1platform-content-ai'),
'errors' => __('errors', '1platform-content-ai'),
'warnings' => __('warnings', '1platform-content-ai'),
'noIssues' => __('No issues', '1platform-content-ai'),
'keyHeader' => [
'queries' => __('Query', '1platform-content-ai'),
'pages' => __('Page', '1platform-content-ai'),
'countries' => __('Country', '1platform-content-ai'),
],
],
]
);
}
}