Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use in Navigation block
  • Loading branch information
ockham committed Jan 28, 2025
commit 87d8855f7158178c243713fd2bde3f3e13a129d4
22 changes: 11 additions & 11 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,12 @@
// it encounters whitespace. This code strips it.
$blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );

// Run Block Hooks algorithm to inject hooked blocks.
$markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post );
$root_nav_block = parse_blocks( $markup )[0];

$blocks = isset( $root_nav_block['innerBlocks'] ) ? $root_nav_block['innerBlocks'] : $blocks;
// Re-serialize, and run Block Hooks algorithm to inject hooked blocks.
// TODO: See if we can move the gutenberg_apply_block_hooks_to_post_content() call
// before the parse_blocks() call further above, to avoid the extra serialization/parsing.
$markup = serialize_blocks( $blocks );
$markup = gutenberg_apply_block_hooks_to_post_content( $markup, $navigation_post );

Check failure on line 248 in packages/block-library/src/navigation/index.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

It's not allowed to call the "gutenberg_apply_block_hooks_to_post_content()" function as its name matches the forbidden pattern: "/^[Gg]utenberg.*$/".
$blocks = parse_blocks( $markup );

// TODO - this uses the full navigation block attributes for the
// context which could be refined.
Expand Down Expand Up @@ -1077,12 +1078,11 @@

// Run Block Hooks algorithm to inject hooked blocks.
// We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks.
$markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post );
$blocks = parse_blocks( $markup );

if ( isset( $blocks[0]['innerBlocks'] ) ) {
$fallback_blocks = $blocks[0]['innerBlocks'];
}
// TODO: See if we can move the gutenberg_apply_block_hooks_to_post_content() call
// before the parse_blocks() call further above, to avoid the extra serialization/parsing.
$markup = serialize_blocks( $fallback_blocks );
$markup = gutenberg_apply_block_hooks_to_post_content( $markup, $navigation_post );

Check failure on line 1084 in packages/block-library/src/navigation/index.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

It's not allowed to call the "gutenberg_apply_block_hooks_to_post_content()" function as its name matches the forbidden pattern: "/^[Gg]utenberg.*$/".
$fallback_blocks = parse_blocks( $markup );
}

/**
Expand Down
Loading