Make WordPress Core


Ignore:
Timestamp:
05/10/2022 04:20:59 PM (5 years ago)
Author:
hellofromTonya
Message:

Editor: Update WordPress packages for 6.0 RC 2.

[53377] Included cherry-picked commits from the Gutenberg plugin that fix bugs discovered after WordPress 6.0 RC 1.

[53378] Includes cherry-picked commit from the Gutenberg plugin that fix a bug discovered just before WordPress 6.0 RC 2.

Props zieladam, ndiego, kebbet, hellofromTonya.
Merges [53377] and [53378] to the 6.0 branch.
Fixes #55567.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-includes/blocks/navigation.php

    r53157 r53381  
    352352
    353353/**
     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 */
     360function 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 */
     372function 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/**
    354389 * Renders the `core/navigation` block on server.
    355390 *
    … …  
    501536                $text_decoration ? array( $text_decoration_class ) : array()
    502537        );
     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        }
    503543
    504544        $inner_blocks_html = '';
Note: See TracChangeset for help on using the changeset viewer.