Yoast\WP\SEO\Generators

Schema_Generator::add_schema_blocks_graph_pieces()protectedYoast 1.0

Adds schema graph pieces from Gutenberg blocks on the current page to the given schema graph.

Think of blocks like the Yoast FAQ block or the How To block.

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

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

Возвращает

Массив. The graph with the schema blocks graph pieces added.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->add_schema_blocks_graph_pieces( $graph, $context );
$graph(массив) (обязательный)
The current schema graph.
$context(Meta_Tags_Context) (обязательный)
The meta tags context.

Код Schema_Generator::add_schema_blocks_graph_pieces() Yoast 22.4

protected function add_schema_blocks_graph_pieces( $graph, $context ) {
	foreach ( $context->blocks as $block_type => $blocks ) {
		foreach ( $blocks as $block ) {
			$block_type = \strtolower( $block['blockName'] );

			/**
			 * Filter: 'wpseo_schema_block_<block-type>'.
			 * This filter is documented in the `generate_graph()` function in this class.
			 */
			$graph = \apply_filters( 'wpseo_schema_block_' . $block_type, $graph, $block, $context );

			if ( isset( $block['attrs']['yoast-schema'] ) ) {
				$graph[] = $this->schema_replace_vars_helper->replace( $block['attrs']['yoast-schema'], $context->presentation );
			}
		}
	}

	return $graph;
}