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.

Built from https://develop.svn.wordpress.org/trunk@52797


git-svn-id: http://core.svn.wordpress.org/trunk@52386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-02-25 12:44:04 +00:00
parent 2ae4784ca0
commit b26449d863
2 changed files with 7 additions and 4 deletions

View File

@ -4780,9 +4780,12 @@ function get_post_galleries( $post, $html = true ) {
continue;
}
// All blocks nested inside non-Gallery blocks should be in the root array.
if ( $has_inner_blocks && 'core/gallery' !== $block['blockName'] ) {
// Skip non-Gallery blocks.
if ( 'core/gallery' !== $block['blockName'] ) {
// Move inner blocks into the root array before skipping.
if ( $has_inner_blocks ) {
array_push( $post_blocks, ...$block['innerBlocks'] );
}
continue;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-52796';
$wp_version = '6.0-alpha-52797';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.