wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_get_first_block › WordPress Function
Since6.3.0
Deprecatedn/a
› wp_get_first_block ( $blocks, $block_name )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Finds the first occurrence of a specific block in an array of blocks.
Related Functions: wp_set_post_lock, _get_list_table, wp_check_post_lock, wp_get_post_cats, wp_list_pluck
Source
function wp_get_first_block( $blocks, $block_name ) { foreach ( $blocks as $block ) { if ( $block_name === $block['blockName'] ) { return $block; } if ( ! empty( $block['innerBlocks'] ) ) { $found_block = wp_get_first_block( $block['innerBlocks'], $block_name ); if ( ! empty( $found_block ) ) { return $found_block; } } } return array(); }