Yoast\WP\SEO\Schema_Aggregator\Application\Enhancement

Person_Schema_Enhancer::enhance_schema_piece │ protected │ Yoast 1.0

Enhance a single schema piece

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

Хуков нет.

Возвращает

array<string>. The enhanced schema data.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->enhance_schema_piece( $schema_data, $indexable ): array;
$schema_data(array) (обязательный)
The schema data to enhance.
$indexable(Indexable) (обязательный)
The indexable object that is the source of the schema piece.

Код Person_Schema_Enhancer::enhance_schema_piece() Yoast 28.9

protected function enhance_schema_piece( array $schema_data, Indexable $indexable ): array {
	try {
		// Add jobTitle if enabled and not already present.
		if ( $this->config->is_enhancement_enabled( 'person_job_title' ) && ! isset( $schema_data['jobTitle'] ) ) {
			$job_title = $this->get_person_job_title( $indexable->author_id );
			if ( $job_title !== null && $job_title !== '' ) {
				$schema_data['jobTitle'] = $job_title;
			}
		}

		return $schema_data;
	} catch ( Exception $e ) {
		return $schema_data;
	}
}