Yoast\WP\SEO\Generators
Schema_Generator::generate()
Returns a Schema graph array.
Метод класса: Schema_Generator{}
Хуки из метода
Возвращает
Массив
. The graph.
Использование
$Schema_Generator = new Schema_Generator(); $Schema_Generator->generate( $context );
- $context(Meta_Tags_Context) (обязательный)
- The meta tags context.
Код Schema_Generator::generate() Schema Generator::generate Yoast 24.9
public function generate( Meta_Tags_Context $context ) { $pieces = $this->get_graph_pieces( $context ); $this->schema_replace_vars_helper->register_replace_vars( $context ); foreach ( \array_keys( $context->blocks ) as $block_type ) { /** * Filter: 'wpseo_pre_schema_block_type_<block-type>' - Allows hooking things to change graph output based on the blocks on the page. * * @param WP_Block_Parser_Block[] $blocks All the blocks of this block type. * @param Meta_Tags_Context $context A value object with context variables. */ \do_action( 'wpseo_pre_schema_block_type_' . $block_type, $context->blocks[ $block_type ], $context ); } // Do a loop before everything else to inject the context and helpers. foreach ( $pieces as $piece ) { if ( \is_a( $piece, Abstract_Schema_Piece::class ) ) { $piece->context = $context; $piece->helpers = $this->helpers; } } $pieces_to_generate = $this->filter_graph_pieces_to_generate( $pieces ); $graph = $this->generate_graph( $pieces_to_generate, $context ); $graph = $this->add_schema_blocks_graph_pieces( $graph, $context ); $graph = $this->finalize_graph( $graph, $context ); return [ '@context' => 'https://schema.org', '@graph' => $graph, ]; }