resolver = $resolver; $this->location_evaluator = $location_evaluator; } /** * Whether the plugin outputs anything for the current request: a blog * index that is either the front page, or a supported "Posts page" * matched by the location rules of its post type. */ public function applies(): bool { if ( ! CurrentBlogIndex::is_active() ) { return false; } if ( is_front_page() ) { return true; } $page = CurrentBlogIndex::posts_page(); return null !== $page && $this->location_evaluator->applies( $page ); } /** * applies(), plus — on a "Posts page" — the page post type's schema * toggle, the same gate SchemaOutput uses for singular pages. */ public function applies_to_schema(): bool { if ( ! $this->applies() ) { return false; } $page = $this->posts_page(); return null === $page || $this->location_evaluator->applies_to_schema( $page ); } public function posts_page(): ?\WP_Post { return CurrentBlogIndex::posts_page(); } /** * Full document title, or '' to keep the one WordPress builds. Listing * pages 2+ get a page suffix, otherwise they would all share one title. */ public function title(): string { $page = $this->posts_page(); if ( null === $page ) { return ''; } $title = $this->resolver->title( $page ); if ( '' === $title || CurrentBlogIndex::page_number() < 2 ) { return $title; } /* translators: %d: page number of a paginated post listing. */ return $title . ' - ' . sprintf( __( 'Page %d', 'acez-seo' ), CurrentBlogIndex::page_number() ); } /** * Name of the listing itself — the page title, or the site name on a * "latest posts" front page (og:title fallback, CollectionPage name). */ public function name(): string { $page = $this->posts_page(); return null !== $page ? get_the_title( $page ) : (string) get_bloginfo( 'name' ); } public function description(): string { $page = $this->posts_page(); $description = null !== $page ? $this->resolver->description( $page ) : ''; return '' !== $description ? $description : wp_strip_all_tags( (string) get_bloginfo( 'description' ) ); } /** * Raw (unescaped) canonical URL. Page 1 of a "Posts page" honours the * custom canonical from its meta box; listing pages 2+ are canonical to * themselves (Google's guidance for paginated series). */ public function canonical(): string { $page = $this->posts_page(); if ( null !== $page && CurrentBlogIndex::page_number() < 2 ) { return $this->resolver->canonical( $page ); } return CurrentBlogIndex::url(); } /** * @return array{index: bool, follow: bool}|null Null on a "latest posts" front page. */ public function robots(): ?array { $page = $this->posts_page(); return null !== $page ? $this->resolver->robots( $page ) : null; } public function og_image_url(): string { $page = $this->posts_page(); return null !== $page ? $this->resolver->og_image_url( $page ) : ''; } public function twitter_card(): string { $page = $this->posts_page(); $card = null !== $page ? $this->resolver->twitter_card( $page ) : ''; if ( '' !== $card ) { return $card; } return '' !== $this->og_image_url() ? 'summary_large_image' : 'summary'; } }