Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gallery: update the get_post_galleries method to account for gallery blocks #1788

Closed

Conversation

glendaviesnz
Copy link

@glendaviesnz glendaviesnz commented Oct 29, 2021

Description

Currently the get_post_galleries method will only handle gallery shortcodes. A trac ticket has been open for some time to rectify this, and in the meantime a new version of the gallery block is about to be released which uses innerblocks, so the diffs on this ticket will no longer be sufficient.

This PR adds support for both versions of the gallery block

There was an alternative approach at #1783 which tidies this large method up into a series of smaller methods. This PR makes for a much longer and harder to grok get_post_galleries method, but avoids adding extra methods to global namespace - open to taking either approach depending on which people prefer.

To test:

  • Check out this PR to local wp dev env along with the latest version of the gutenberg plugin
  • Add a theme that makes use of the get_post_galleries method, eg. Arbutus
  • Add several posts using the Gallery post type - add a short code, gallery block, and v2 gallery block (turn on gallery experiment to add a v2 block)
  • The the homepage of the site and check that all 3 galleries display as expected

Screen Shot 2021-10-27 at 4 06 49 PM

Trac ticket: https://core.trac.wordpress.org/ticket/43826

@glendaviesnz glendaviesnz changed the title Gallery: update the get_post_galleries method to account for gallery blocks - V2 Gallery: update the get_post_galleries method to account for gallery blocks Oct 29, 2021
@ramonjd
Copy link
Member

ramonjd commented Oct 29, 2021

This is testing well for me.

I tried with Classic Block/short code, v1, v2 galleries

Before
Screen Shot 2021-10-27 at 2 41 38 pm

After
Screen Shot 2021-10-29 at 8 55 05 pm

src/wp-includes/media.php Outdated Show resolved Hide resolved
@glendaviesnz
Copy link
Author

Have added initial unit tests - still need to add some tests for the new gallery format

@hellofromtonya
Copy link
Contributor

Closing in preference to PR #1864.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants