Yoast\WP\SEO\Generators\Schema

Article::generate()publicYoast 1.0

Returns Article data.

Метод класса: Article{}

Хуков нет.

Возвращает

Массив. Article data.

Использование

$Article = new Article();
$Article->generate();

Код Article::generate() Yoast 24.0

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 ),
		'dateModified'     => $this->helpers->date->format( $this->context->post->post_modified_gmt ),
		'mainEntityOfPage' => [ '@id' => $this->context->main_schema_id ],
		'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;
}