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 shortcode fallback to respect post_gallery filter #10392

Closed
wants to merge 2 commits into from

Conversation

antpb
Copy link
Contributor

@antpb antpb commented Oct 8, 2018

Description

This PR is an first pass attempt at providing a fallback to the gallery shortcode that will allow support for the post_gallery filter. More information can be found here: #1451

This PR conditionally registers the callback function based on has_filter( 'post_gallery')
I'm opening this PR to have discussion on this approach.

@antpb
Copy link
Contributor Author

antpb commented Oct 8, 2018

Currently having issues getting the render callback function to register in register_block_type. I've commented out the has_filter check as I figure out why the function is not registering

@gziolo gziolo requested review from mcsf and ellatrix February 1, 2019 09:23
@gziolo gziolo added [Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Shortcodes Related to shortcode functionality labels Feb 1, 2019
@gziolo gziolo modified the milestone: 5.2 (Gutenberg) Feb 7, 2019
@gziolo
Copy link
Member

gziolo commented Feb 7, 2019

What was needed in this issue was a way to parse the ids from the Gutenberg gallery. This has been achieved in #11540 so I'll be closing this.

@antpb I noticed your comment that the parent issue was resolved. I'm closing this PR. Feel free to reopen if you think that it still needs to be implemented.

@gziolo gziolo closed this Feb 7, 2019
@tyrann0us
Copy link
Contributor

tyrann0us commented Feb 11, 2019

What was needed in this issue was a way to parse the ids from the Gutenberg gallery. This has been achieved in #11540 so I'll be closing this.
@antpb in #1451 (comment)

@gziolo, if I understand it correctly, the ability to parse IDs from the gallery still doesn't allow plugin/theme authors to change the markup of a gallery created with the "Gallery" block using the post_gallery filter or any other way. In my opinion, neither #1451 nor this PR (#10392) should have been closed.

@gziolo
Copy link
Member

gziolo commented Feb 11, 2019

It's perfectly fine to use the following logic in the plugin and completely override the output which JS code generated with save function:

register_block_type(
    'core/gallery',
    array(
        'render_callback' => 'my_plugin_render_block_gallery',
    )
);

Do you see any issue with such approach? By the way, the long term plan is to have all blocks registered on the server as proposed in #13693. When that happens it should be possible to be able to filter all settings that get registered using register_block_type (unless it is possible as of today - I don't know to be honest - it's part of WordPress core codebase).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Shortcodes Related to shortcode functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants