Make WordPress Core


Ignore:
Timestamp:
05/10/2022 02:47:10 PM (3 years ago)
Author:
gziolo
Message:

Editor: Update WordPress packages for 6.0 RC 2

Included cherry-picked commits from the Gutenberg plugin that fix bugs discovere after WordPress 6.0 RC 1.

Props zieladam, ndiego, hellofromtonya.
See #55567.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/navigation.php

    r53157 r53377  
    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.