Skip to content

Commit

Permalink
Sharing block: remove check for existing block in post content (#38727)
Browse files Browse the repository at this point in the history
This is no longer necessary after some improvements to the Block Hooks API.
  • Loading branch information
jeherve authored Aug 20, 2024
1 parent e13b134 commit e59270f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

Sharing Block: improve performance when hooking the block into single post templates.
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,6 @@ function add_block_to_single_posts_template( $hooked_block_types, $relative_posi
return $hooked_block_types;
}

$content = $context->content ?? '';
// Check if the block is already in the template. If so, abort.
if ( false !== strpos( $content, 'wp:' . PARENT_BLOCK_NAME ) ) {
return $hooked_block_types;
}

$hooked_block_types[] = PARENT_BLOCK_NAME;
return $hooked_block_types;
}
Expand Down

0 comments on commit e59270f

Please sign in to comment.