| 481 | * Check for a single parent block |
| 482 | */ |
| 483 | function check_for_single_parent() { |
| 484 | if ( empty( $this->blocks ) || ! is_array( $this->blocks ) ) { |
| 485 | return; |
| 486 | } |
| 487 | |
| 488 | $top_level_blocks = array_filter( |
| 489 | $this->blocks, |
| 490 | function( $block ) { |
| 491 | return ! isset( $block->parent ) || is_null( $block->parent ); |
| 492 | } |
| 493 | ); |
| 494 | |
| 495 | if ( count( $top_level_blocks ) > 1 ) { |
| 496 | $list = array_map( |
| 497 | function( $block ) { |
| 498 | return ! empty( $block->title ) ? $block->title : $block->name; |
| 499 | }, |
| 500 | $top_level_blocks |
| 501 | ); |
| 502 | $this->record_result( |
| 503 | __FUNCTION__, |
| 504 | 'warning', |
| 505 | sprintf( |
| 506 | /* translators: %s is a list of block names. */ |
| 507 | __( 'More than one top level block was found: %s', 'wporg-plugins' ), |
| 508 | implode( ', ', $list ) |
| 509 | ), |
| 510 | $block_name |
| 511 | ); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /** |