Yoast\WP\SEO\Generators
Schema_Generator::get_graph_pieces
Gets all the graph pieces we need.
Метод класса: Schema_Generator{}
Хуки из метода
Возвращает
Abstract_Schema_Piece[]. A filtered array of graph pieces.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_graph_pieces( $context );
- $context(Meta_Tags_Context) (обязательный)
- The meta tags context.
Код Schema_Generator::get_graph_pieces() Schema Generator::get graph pieces Yoast 28.4
protected function get_graph_pieces( $context ) {
if ( $context->indexable->object_type === 'post' && \post_password_required( $context->post ) ) {
$schema_pieces = [
new Schema\WebPage(),
new Schema\Website(),
new Schema\Organization(),
];
\add_filter( 'wpseo_schema_webpage', [ $this, 'protected_webpage_schema' ], 1 );
}
else {
$schema_pieces = [
new Schema\Article(),
new Schema\WebPage(),
new Schema\Main_Image(),
new Schema\Breadcrumb(),
new Schema\Website(),
new Schema\Organization(),
new Schema\Person(),
new Schema\Author(),
new Schema\FAQ(),
new Schema\HowTo(),
];
}
/**
* Filter: 'wpseo_schema_graph_pieces' - Allows adding pieces to the graph.
*
* @param array $pieces The schema pieces.
* @param Meta_Tags_Context $context An object with context variables.
*/
return \apply_filters( 'wpseo_schema_graph_pieces', $schema_pieces, $context );
}