Yoast\WP\SEO\Generators\Schema
HowTo::add_how_to()
Generates the HowTo schema for a block.
Метод класса: HowTo{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->add_how_to( $graph, $block, $index );
- $graph(массив) (обязательный) (передается по ссылке — &)
- Our Schema data.
- $block(массив) (обязательный)
- The How-To block content.
- $index(int) (обязательный)
- The index of the current block.
Код HowTo::add_how_to() HowTo::add how to Yoast 20.8
protected function add_how_to( &$graph, $block, $index ) { $data = [ '@type' => 'HowTo', '@id' => $this->context->canonical . '#howto-' . ( $index + 1 ), 'name' => $this->helpers->schema->html->smart_strip_tags( $this->helpers->post->get_post_title_with_fallback( $this->context->id ) ), 'mainEntityOfPage' => [ '@id' => $this->context->main_schema_id ], 'description' => '', ]; if ( $this->context->has_article ) { $data['mainEntityOfPage'] = [ '@id' => $this->context->main_schema_id . Schema_IDs::ARTICLE_HASH ]; } if ( isset( $block['attrs']['jsonDescription'] ) ) { $data['description'] = $this->helpers->schema->html->sanitize( $block['attrs']['jsonDescription'] ); } $this->add_duration( $data, $block['attrs'] ); $this->add_steps( $data, $block['attrs']['steps'] ); $data = $this->helpers->schema->language->add_piece_language( $data ); $graph[] = $data; }