Skip to content

Commit

Permalink
Add guards for undefined indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Davies authored and ramonjd committed Nov 5, 2021
1 parent a958531 commit ff4ba58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/block-library/src/gallery/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function render_block_core_gallery_data( $parsed_block ) {
if ( 'core/gallery' === $parsed_block['blockName'] ) {
foreach ( $parsed_block['innerBlocks'] as $key => $inner_block ) {
if ( 'core/image' === $inner_block['blockName'] ) {
if ( ! $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] ) {
if ( ! isset( $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] ) && isset( $inner_block['attrs']['id'] ) ) {
$parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] = esc_attr( $inner_block['attrs']['id'] );
}
}
Expand Down

0 comments on commit ff4ba58

Please sign in to comment.