Yoast\WP\SEO\Generators\Schema
FAQ::generate() public Yoast 1.0
Render a list of questions, referencing them by ID.
{} Это метод класса: FAQ{}
Хуков нет.
Возвращает
Массив. $data Our Schema graph.
Использование
$FAQ = new FAQ(); $FAQ->generate();
Код FAQ::generate() FAQ::generate Yoast 15.6.2
public function generate() {
$ids = [];
$graph = [];
$number_of_items = 0;
foreach ( $this->context->blocks['yoast/faq-block'] as $block ) {
foreach ( $block['attrs']['questions'] as $index => $question ) {
if ( ! isset( $question['jsonAnswer'] ) || empty( $question['jsonAnswer'] ) ) {
continue;
}
$ids[] = [ '@id' => $this->context->canonical . '#' . \esc_attr( $question['id'] ) ];
// Index + 1 below so we start at 1 and count from there.
$graph[] = $this->generate_question_block( $question, ( $index + 1 ) );
++$number_of_items;
}
}
$extra_graph_entries = [
'@type' => 'ItemList',
'mainEntityOfPage' => [ '@id' => $this->context->main_schema_id ],
'numberOfItems' => $number_of_items,
'itemListElement' => $ids,
];
\array_unshift( $graph, $extra_graph_entries );
return $graph;
}