Yoast\WP\SEO\Abilities\Infrastructure

Abstract_SEO_Field_Map::get_shared_seo_fields │ protected │ Yoast 1.0

Returns the SEO data fields every entity type shares, keyed by output-schema property name.

Alongside the raw stored fields, each rendered companion (*_rendered) carries the value as it is actually output on the front end: the global default template is applied where no custom value is set, and replacement variables are expanded.

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

Хуков нет.

Возвращает

array<string, string|bool|null>. The shared SEO data fields.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_shared_seo_fields( $indexable, $meta ): array;
$indexable(Indexable) (обязательный)
The indexable to read from.
$meta(Meta|false) (обязательный)
The meta values for the entity, or false when unavailable.

Код Abstract_SEO_Field_Map::get_shared_seo_fields() Yoast 28.9

protected function get_shared_seo_fields( $indexable, $meta ): array {
	return [
		'seo_title'                       => $indexable->title,
		'seo_title_rendered'              => $this->rendered( $meta, 'seo_title' ),
		'meta_description'                => $indexable->description,
		'meta_description_rendered'       => $this->rendered( $meta, 'meta_description' ),
		'focus_keyphrase'                 => $indexable->primary_focus_keyword,
		'canonical'                       => $indexable->canonical,
		'canonical_rendered'              => $this->rendered( $meta, 'canonical' ),
		'is_cornerstone'                  => (bool) $indexable->is_cornerstone,
		'noindex'                         => $indexable->is_robots_noindex,
		'open_graph_title'                => $indexable->open_graph_title,
		'open_graph_title_rendered'       => $this->rendered( $meta, 'open_graph_title' ),
		'open_graph_description'          => $indexable->open_graph_description,
		'open_graph_description_rendered' => $this->rendered( $meta, 'open_graph_description' ),
		'twitter_title'                   => $indexable->twitter_title,
		'twitter_title_rendered'          => $this->rendered( $meta, 'twitter_title' ),
		'twitter_description'             => $indexable->twitter_description,
		'twitter_description_rendered'    => $this->rendered( $meta, 'twitter_description' ),
		'seo_score'                       => WPSEO_Rank::from_numeric_score( (int) $indexable->primary_focus_keyword_score )->get_rank(),
		'readability_score'               => WPSEO_Rank::from_numeric_score( (int) $indexable->readability_score )->get_rank(),
		// A zero score maps to NO_FOCUS ("not available") via the rank ranges, same as the scores above.
		'inclusive_language_score'        => WPSEO_Rank::from_numeric_score( (int) $indexable->inclusive_language_score )->get_rank(),
	];
}