Yoast\WP\SEO\Abilities\Infrastructure

Abstract_SEO_Field_Map::rendered │ protected │ Yoast 1.0

Returns the front-end output for a rendered field, or null when nothing is output.

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

Хуков нет.

Возвращает

string|null. The rendered value, or null when empty or unavailable.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->rendered( $meta, $output_field ): ?string;
$meta(Meta|false) (обязательный)
The meta values for the entity, or false when unavailable.
$output_field(строка) (обязательный)
The rendered output field name.

Код Abstract_SEO_Field_Map::rendered() Yoast 28.9

protected function rendered( $meta, string $output_field ): ?string {
	if ( ! $meta instanceof Meta ) {
		return null;
	}

	$value = $meta->{ self::RENDERED_FIELDS[ $output_field ] };

	// Treat an empty presented value as "nothing is output" rather than an empty string.
	if ( $value === null || $value === '' ) {
		return null;
	}

	return (string) $value;
}