Yoast\WP\SEO\Generators

Schema_Generator::type_filter()privateYoast 1.0

Allows filtering the graph piece by its schema type.

Note: We removed the Abstract_Schema_Piece type-hint from the $graph_piece_generator argument, because it caused conflicts with old code, Yoast SEO Video specifically.

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

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

Возвращает

Массив. The filtered graph piece.

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

// private - только в коде основоного (родительского) класса
$result = $this->type_filter( $graph_piece, $identifier, $context, $graph_piece_generator, $graph_piece_generators );
$graph_piece(массив) (обязательный)
The graph piece we're filtering.
$identifier(строка) (обязательный)
The identifier of the graph piece that is being filtered.
$context(Meta_Tags_Context) (обязательный)
The meta tags context.
$graph_piece_generator(Abstract_Schema_Piece) (обязательный)
A value object with context variables.
$graph_piece_generators(Abstract_Schema_Piece[]) (обязательный)
A value object with context variables.

Код Schema_Generator::type_filter() Yoast 22.4

private function type_filter( $graph_piece, $identifier, Meta_Tags_Context $context, $graph_piece_generator, array $graph_piece_generators ) {
	$types = $this->get_type_from_piece( $graph_piece );
	foreach ( $types as $type ) {
		$type = \strtolower( $type );

		// Prevent running the same filter twice. This makes sure we run f/i. for 'author' and for 'person'.
		if ( $type && $type !== $identifier ) {
			/**
			 * Filter: 'wpseo_schema_<type>' - Allows changing graph piece output by @type.
			 *
			 * @param array                   $graph_piece            The graph piece to filter.
			 * @param Meta_Tags_Context       $context                A value object with context variables.
			 * @param Abstract_Schema_Piece   $graph_piece_generator  A value object with context variables.
			 * @param Abstract_Schema_Piece[] $graph_piece_generators A value object with context variables.
			 */
			$graph_piece = \apply_filters( 'wpseo_schema_' . $type, $graph_piece, $context, $graph_piece_generator, $graph_piece_generators );
		}
	}

	return $graph_piece;
}