Make WordPress Core


Ignore:
Timestamp:
03/28/2022 08:51:00 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.
Merges [52797] to the 5.9 branch.
Fixes #55203.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/media.php

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