meta_resolver = $meta_resolver; $this->post_meta = $post_meta; } public function get_id(): string { return 'Article'; } public function applies_to( \WP_Post $post ): bool { // M66: a user-forced type (or 'none') supersedes automatic detection — // ForcedSchemaType emits the main node instead (or nothing at all). if ( '' !== ForcedSchemaType::override_for( $this->post_meta, $post ) ) { return false; } return 'post' === $post->post_type; } public function build( \WP_Post $post ): array { $title = $this->meta_resolver->title( $post ); $title = '' !== $title ? $title : get_the_title( $post ); $data = array( '@type' => 'Article', '@id' => SchemaIds::article( $post ), 'headline' => wp_strip_all_tags( $title ), 'description' => $this->meta_resolver->description( $post ), 'mainEntityOfPage' => array( '@id' => (string) get_permalink( $post ) ), 'datePublished' => get_the_date( DATE_W3C, $post ), 'dateModified' => get_the_modified_date( DATE_W3C, $post ), 'author' => array( '@id' => SchemaIds::person( (int) $post->post_author ) ), 'publisher' => array( '@id' => SchemaIds::organization() ), ); $image = $this->meta_resolver->og_image_url( $post ); if ( '' !== $image ) { $data['image'] = $image; } return $data; } }