-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Let ID-less [gallery] shortcodes fall to Shortcode block #25144
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mcsf
added
Backwards Compatibility
Issues or PRs that impact backwards compatability
[Feature] Shortcodes
Related to shortcode functionality
[Block] Gallery
Affects the Gallery Block - used to display groups of images
labels
Sep 8, 2020
Size Change: +9 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
ntsekouras
approved these changes
Sep 8, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and looks good 👍
This was referenced Mar 18, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Backwards Compatibility
Issues or PRs that impact backwards compatability
[Block] Gallery
Affects the Gallery Block - used to display groups of images
[Feature] Shortcodes
Related to shortcode functionality
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #11551
Description
Until now, the Gallery block was the recipient of all
[gallery]
shortcodes. This works well for the most common use of the shortcode, when identifiers for media objects are specified ([gallery ids="1,2,3"]
) but fails to accommodate other scenarios, as detailed in comments in #11551, especially whenever WordPress post attachments are concerned (e.g.[gallery]
,[gallery id="10"]
).This pull request adds an
isMatch
predicate to the Gallery block's shortcode transform so that it only catches shortcodes which explicitly provide gallery objects via theids
attribute. Otherwise, assume that the shortcode is doing more work than the Gallery block can automatically accommodate and let the transform be picked up by the Shortcode block — thus leaving the original shortcode untouched.How has this been tested?
Using the Classic block (or Classic editor, or the CLI), create a draft with the following shortcodes:
[gallery ids="1,2,3"]
, where the integers represent the IDs of existing media library images[gallery]
, assuming that there are images attached to the present post (but not needed for the purposes of testing)[gallery id="1"]
, assuming that 1 is the ID of a WP post with attachmentsPress the Classic block's Convert to Blocks button. Verify that the first shortcode is converted into a Gallery block with the expected images. Verify that the remaining shortcodes are converted into Shortcode blocks and that the shortcodes therein are preserved.
The same should happen by directly pasting these shortcodes onto the block editor.
Types of changes
Enhancement. Backwards compatibility.
Checklist: