eces to the graph. * * @param WPSEO_Schema_Context $context An object with context variables. * * @api array $pieces The schema pieces. */ return apply_filters( 'wpseo_schema_graph_pieces', $pieces, $this->context ); } /** * Parse the blocks and pass them on to our head. */ private function parse_blocks() { if ( ! function_exists( 'parse_blocks' ) ) { return; } if ( ! is_singular() ) { return; } $this->get_parsed_blocks(); foreach ( array_keys( $this->parsed_blocks ) as $block_type ) { /** * Filter: 'wpseo_pre_schema_block_type_' - Allows hooking things to change graph output based on the blocks on the page. * * @param string $block_type The block type. * @param array $blocks All the blocks of this block type. * @param WPSEO_Schema_Context $context A value object with context variables. */ do_action( 'wpseo_pre_schema_block_type_' . $block_type, $this->parsed_blocks[ $block_type ], $this->context ); } } /** * Parse the blocks and loop through them. */ private function get_parsed_blocks() { $post = get_post(); $parsed_blocks = parse_blocks( $post->post_content ); foreach ( $parsed_blocks as $block ) { if ( ! isset( $this->parsed_blocks[ $block['blockName'] ] ) || ! is_array( $this->parsed_blocks[ $block['blockName'] ] ) ) { $this->parsed_blocks[ $block['blockName'] ] = []; } $this->parsed_blocks[ $block['blockName'] ][] = $block; } } }