Yoast\WP\SEO\Surfaces\Values

Meta::get_head()publicYoast 1.0

Returns the output as would be presented in the head.

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

Хуки из метода

Возвращает

Объект. The HTML and JSON presentation of the head metadata.

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

$Meta = new Meta();
$Meta->get_head();

Код Meta::get_head() Yoast 22.4

public function get_head() {
	$presenters = $this->get_presenters();

	/** This filter is documented in src/integrations/front-end-integration.php */
	$presentation = \apply_filters( 'wpseo_frontend_presentation', $this->context->presentation, $this->context );

	$html_output      = '';
	$json_head_fields = [];

	foreach ( $presenters as $presenter ) {
		$presenter->presentation = $presentation;
		$presenter->replace_vars = $this->replace_vars;
		$presenter->helpers      = $this->helpers;

		$html_output .= $this->create_html_presentation( $presenter );
		$json_field   = $this->create_json_field( $presenter );

		// Only use the output of presenters that could successfully present their data.
		if ( $json_field !== null && ! empty( $json_field->key ) ) {
			$json_head_fields[ $json_field->key ] = $json_field->value;
		}
	}
	$html_output = \trim( $html_output );

	return (object) [
		'html' => $html_output,
		'json' => $json_head_fields,
	];
}