Yoast\WP\SEO\Generators\Schema
Article::generate
Returns Article data.
Метод класса: Article{}
Хуков нет.
Возвращает
Массив. Article data.
Использование
$Article = new Article(); $Article->generate();
Код Article::generate() Article::generate Yoast 26.3
public function generate() {
$author = \get_userdata( $this->context->post->post_author );
$data = [
'@type' => $this->context->schema_article_type,
'@id' => $this->context->canonical . Schema_IDs::ARTICLE_HASH,
'isPartOf' => [ '@id' => $this->context->main_schema_id ],
'author' => [
'name' => ( $author instanceof WP_User ) ? $this->helpers->schema->html->smart_strip_tags( $author->display_name ) : '',
'@id' => $this->helpers->schema->id->get_user_schema_id( $this->context->post->post_author, $this->context ),
],
'headline' => $this->helpers->schema->html->smart_strip_tags( $this->helpers->post->get_post_title_with_fallback( $this->context->id ) ),
'datePublished' => $this->helpers->date->format( $this->context->post->post_date_gmt ),
];
if ( \strtotime( $this->context->post->post_modified_gmt ) > \strtotime( $this->context->post->post_date_gmt ) ) {
$data['dateModified'] = $this->helpers->date->format( $this->context->post->post_modified_gmt );
}
$data['mainEntityOfPage'] = [ '@id' => $this->context->main_schema_id ];
$data['wordCount'] = $this->word_count( $this->context->post->post_content, $this->context->post->post_title );
if ( $this->context->post->comment_status === 'open' ) {
$data['commentCount'] = \intval( $this->context->post->comment_count, 10 );
}
if ( $this->context->site_represents_reference ) {
$data['publisher'] = $this->context->site_represents_reference;
}
$data = $this->add_image( $data );
$data = $this->add_keywords( $data );
$data = $this->add_sections( $data );
$data = $this->helpers->schema->language->add_piece_language( $data );
if ( \post_type_supports( $this->context->post->post_type, 'comments' ) && $this->context->post->comment_status === 'open' ) {
$data = $this->add_potential_action( $data );
}
return $data;
}