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

Fix compatibility issues with shortcodes in blocks and Gutenberg 18.1+ #517

Merged
merged 3 commits into from
May 9, 2024

Conversation

adamwoodnz
Copy link
Contributor

@adamwoodnz adamwoodnz commented May 8, 2024

Fixes #513

After WordPress/gutenberg#60349, shortcodes passed via block attributes don't work.

Shortcodes in block markup in patterns do work, so this PR removes the custom block usage and puts the shortcodes directly in the pattern markup. The main reason for using these custom blocks was conditional rendering, which has been moved to the template level.

The result is a fair bit of markup duplication but the reduction of custom block usage and hidden complexity is probably positive.

Testing

  1. Ensure your Gutenberg version is 18.1+
  2. Load the Plugins handbook. Only the First Published and Last Updated (if different from published) meta data should be displayed
  3. Load the Advanced Admin handbook. The dates plus Edit on GitHub and Changelog meta data should be displayed. The GitHub links should include the article title for screen readers only.
  4. Load the Block Editor handbook. The meta data should be the same as the Advanced Admin handbook, but without the Changelog link.
  5. Test all the links

After WordPress/gutenberg#60349, shortcodes passed via block attributes don't work.

Shortcodes in block markup in patterns do work, so stop using custom blocks and move the logic to the template level instead.
@adamwoodnz adamwoodnz requested a review from ryelle May 8, 2024 00:57
Comment on lines -72 to -76
// The block editor handbook doesn't have a changelog.
// We only know it's the changelog because of the linkURL attribute.
if ( 'blocks-handbook' === $post_type && '[article_changelog_link]' === $block['attrs']['linkURL'] ) {
return '';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic replaced by the switch here

Comment on lines -65 to -70
$local_handbooks = array( 'apis-handbook', 'plugin-handbook', 'theme-handbook' );
$post_type = get_post_type();

if ( in_array( $post_type, $local_handbooks ) ) {
return '';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic replaced by reverting the removal of the single-handbook-github.html template

Copy link
Contributor

@ryelle ryelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links & dates all work, checked a few different handbook pages. I left two comments, but this shouldn't need a re-review to merge 👍🏻

The result is a fair bit of markup duplication but the reduction of custom block usage and hidden complexity is probably positive.

Yeah, it's too bad about the duplication, but this is probably closer to how core expects themes to behave, so hopefully less likely to break 🤞🏻

@adamwoodnz adamwoodnz changed the title Move article meta logic from blocks to templates and patterns Fix compatibility issues with shortcodes in blocks and Gutenberg 18.1+ May 8, 2024
@adamwoodnz adamwoodnz merged commit 1c40953 into trunk May 9, 2024
1 check passed
@adamwoodnz adamwoodnz deleted the fix/513-gutenberg-18-1-compat branch May 9, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block Editor Handbook: Improve it on Github links are broken
2 participants