Changeset 53377 for trunk/src/wp-includes/blocks/navigation.php
- Timestamp:
- 05/10/2022 02:47:10 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/navigation.php
r53157 r53377 352 352 353 353 /** 354 * Iterate through all inner blocks recursively and get navigation link block's post IDs. 355 * 356 * @param WP_Block_List $inner_blocks Block list class instance. 357 * 358 * @return array Array of post IDs. 359 */ 360 function block_core_navigation_get_post_ids( $inner_blocks ) { 361 $post_ids = array_map( 'block_core_navigation_from_block_get_post_ids', iterator_to_array( $inner_blocks ) ); 362 return array_unique( array_merge( ...$post_ids ) ); 363 } 364 365 /** 366 * Get post IDs from a navigation link block instance. 367 * 368 * @param WP_Block $block Instance of a block. 369 * 370 * @return array Array of post IDs. 371 */ 372 function block_core_navigation_from_block_get_post_ids( $block ) { 373 $post_ids = array(); 374 375 if ( $block->inner_blocks ) { 376 $post_ids = block_core_navigation_get_post_ids( $block->inner_blocks ); 377 } 378 379 if ( 'core/navigation-link' === $block->name || 'core/navigation-submenu' === $block->name ) { 380 if ( $block->attributes && isset( $block->attributes['kind'] ) && 'post-type' === $block->attributes['kind'] ) { 381 $post_ids[] = $block->attributes['id']; 382 } 383 } 384 385 return $post_ids; 386 } 387 388 /** 354 389 * Renders the `core/navigation` block on server. 355 390 * … … 501 536 $text_decoration ? array( $text_decoration_class ) : array() 502 537 ); 538 539 $post_ids = block_core_navigation_get_post_ids( $inner_blocks ); 540 if ( $post_ids ) { 541 _prime_post_caches( $post_ids, false, false ); 542 } 503 543 504 544 $inner_blocks_html = '';
Note: See TracChangeset
for help on using the changeset viewer.