-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove do_shortcode and wpautop for block template parts (still need to remove shortcode block) #20452
base: trunk
Are you sure you want to change the base?
Conversation
…try/remove-do-shortcode-for-template-parts
Sorry, I closed the wrong PR :) |
I'm still using shortcodes in template parts for times when blocks are not yet available. |
Thinking it's time to revisit this. See #20343 (comment) and the following comments. Autop was removed, but Similarly to autop, there is no good reason to globally support shortcodes in template parts. Shortcodes are old, slow, buggy, limited technology. The shortcode block can be used for now, perhaps to make it a bit easier for some themes and plugins. However thinking best would be to not have it there by default but leave plugins to add/enable it. Reason is that once it is added (by default), there's no getting rid of it, ever. |
I have more examples where I need to use shortcodes because they exist but the equivalent block doesn't.
I also have examples where the shortcode block is not suitable because it adds unwanted paragraphs before and after the shortcode's output. As a workaround I switched to use the custom HTML block Until Gutenberg supports the block equivalent of inline shortcodes then I will continue to need to use these solutions. There is already a published FSE theme that uses shortcodes. See product-content.html in |
@bobbingwide I see... To put this in a "JavaScript perspective", using shortcodes in FSE in 2021 is roughly the equivalent of building a React app (latest well established technology) and then adding Prototype.js and Scriptaculous.js (2008 technology) for the "things that may not be available yet". I believe this would be a pretty poor decision. If you really must use shortcodes outside of post_content and few widgets, I've got few questions:
Right, the shortcode block has some limitations. These may eventually be fixed in Gutenberg although don't think this is a priority. A plugin can also fix this particular limitation pretty easily (I think).
Don't think that's a good idea, old tech vs. new tech, etc. But it's probably worth a ticket (if one doesn't exist already). Also see above, plugins can hook into block parsing and do... pretty much anything they want with all blocks. TL;DR: Currently (without FSE) shortcodes are not supported in "template tags", only in post_content and some widgets. Adding a "global" shortcodes support in FSE sounds like a poor architectural decision. |
The related issue is closed so I'm wondering if this is still relevant anymore? Should we close the PR? |
Relates to issue #20342
Description
This PR removes the wpautop and do_shortcode wrappers for block template parts as suggested by @azaozz in #20343.
How has this been tested?
Screenshots
Types of changes
Bug fix.
Still to-do: Un-list the shortcode block if editing a block-template or block-template part.
Un-listing a block in a context does not seem to be possible yet, as blocks are registered without an attached context. For example, I did not see a way to only register the shortcode block if editing the_content.
The only way I could see to remove the shortcode block was by removing it here:
gutenberg/packages/block-library/src/index.js
Line 117 in cd851b2
But that removes it entirely, for all contexts, not just for the block-template-part editor.
Additionally, since the block-template-part editor is eventually going to be rolled into Full-Site Editing, and editing a
block-template-part
andthe_content
will be possible in that same view (where shortcodes are still allowed) there would have to be a way to disable the shortcode block, but only if editing in a block-template-part area, and otherwise, leave it registered, even if both contexts are being loaded in a single page.Checklist: