post_content)); } } return false; } /** * @param array $robots * @return array */ public function robots(array $robots): array { if ($this->navigated()) { unset($robots['index']); $robots['noindex'] = true; } return $robots; } /** * @param array $robots * @return array */ public function pluginRobots(array $robots): array { if ($this->navigated()) { $robots['index'] = 'noindex'; } return $robots; } public function canonical(string $url): string { if (is_singular('pcwp_event')) { return (string) get_permalink(get_queried_object_id()); } return $url; } public function emptyFuture(): void { $start = sanitize_text_field(wp_unslash($_GET['pcwp_start'] ?? '')); if (! is_post_type_archive('pcwp_event') || ! preg_match('/^\d{4}-\d{2}-\d{2}$/D', $start) || $start <= gmdate('Y-m-d', strtotime('+2 years'))) { return; } if (\ProCalendarWP\Plugin::instance()->events()->occurrences(['start' => $start, 'end' => $start . 'T23:59:59', 'limit' => 1]) === []) { global $wp_query; $wp_query->set_404(); status_header(404); nocache_headers(); } } }