Make WordPress Core


Ignore:
Timestamp:
02/25/2022 12:42:10 PM (3 years ago)
Author:
audrasjb
Message:

Media: Make get_post_galleries() only return galleries.

This change makes sure only gallery content is returned by get_post_galleries(). It fixes an issue where non gallery block content was also returned by the function.

Props BinaryMoon, costdev, glendaviesnz.
Fixes #55203.

File:
1 edited

Legend:

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

    r52725 r52797  
    47814781            }
    47824782
    4783             // All blocks nested inside non-Gallery blocks should be in the root array.
    4784             if ( $has_inner_blocks && 'core/gallery' !== $block['blockName'] ) {
    4785                 array_push( $post_blocks, ...$block['innerBlocks'] );
     4783            // Skip non-Gallery blocks.
     4784            if ( 'core/gallery' !== $block['blockName'] ) {
     4785                // Move inner blocks into the root array before skipping.
     4786                if ( $has_inner_blocks ) {
     4787                    array_push( $post_blocks, ...$block['innerBlocks'] );
     4788                }
    47864789                continue;
    47874790            }
Note: See TracChangeset for help on using the changeset viewer.