Skip to content

Commit c558f49

Browse files
committed
Optimize innerBlocks loop
1 parent 3a06a47 commit c558f49

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

php/media/class-video.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,12 @@ public function has_video_block( $source_block ) {
242242
if ( 'core/video' === $source_block['blockName'] ) {
243243
return true;
244244
}
245-
foreach ( $source_block['innerBlocks'] as $block ) {
246-
if ( $this->has_video_block( $block ) ) {
247-
return true;
245+
246+
if ( ! empty( $source_block['innerBlocks'] ) ) {
247+
foreach ( $source_block['innerBlocks'] as $block ) {
248+
if ( $this->has_video_block( $block ) ) {
249+
return true;
250+
}
248251
}
249252
}
250253

0 commit comments

Comments
 (0)