WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.19k forks source link

Reconsider omission of shortcode block from Block Based Theme Template Parts #23626

Open DaisyOlsen opened 4 years ago

DaisyOlsen commented 4 years ago

Is your feature request related to a problem? Please describe. Shortcodes have been a core functionality of WordPress since version 2.5. As such, there is an extremely wide usage of shortcodes across plugins and themes created by hundreds(more?) of plugins and themes. This is unlikely to immediately stop with the Gutenberg editor despite growing adoption as the primary content creation tool for WordPress.

Describe the solution you'd like I would like to see support for the Gutenberg shortcode block to be included in Block-Based Theme/Full Site Editing functionality currently being developed for inclusion in core.

Describe alternatives you've considered This request is based on my experience working directly with long-time content creators as well as many re-theming projects for existing sites with many and varied plugins dependencies.

An alternative to the immediate removal of this functionality in Block-Based theming would be a larger and longer-term initiative to phase out shortcodes.

epiqueras commented 4 years ago

Related https://github.com/WordPress/gutenberg/pull/20343

cc @youknowriad @azaozz @johnstonphilip

youknowriad commented 4 years ago

Since block-based themes are not an existing API, we're not breaking any backwards compatibility and this more is more likely to encourage people to move away from shortcodes to blocks and formats.

An alternative to the immediate removal of this functionality in Block-Based theming would be a larger and longer-term initiative to phase out shortcodes.

As stated here, I see this as the beginning of the larger and long term phase out of shortcodes as we're not impacting any existing site while encourage folks to adopt the new technologies. Allowing them in block-based themes is likely to encourage their usage still and prevent the long phase out.

azaozz commented 4 years ago

I see this as the beginning of the larger and long term phase out of shortcodes

Yes! At this point shortcodes are the WP equivalent of using HTML tables for layout :) There's absolutely no good reason to use 2007's tech in 2020. There are so many new, better ways to do things.

DaisyOlsen commented 4 years ago

Yes! At this point shortcodes are the WP equivalent of using HTML tables for layout :) There's absolutely no good reason to use 2007's tech in 2020. There are so many new, better ways to do things.

I certainly can’t argue with this, it’s 100% true. This leads me to consider what else could the community be doing to remove barriers for adoption of Gutenberg for content creation. Also what can be done to encourage those that use shortcodes as a go-to solution for client work because it’s familiar to move to the unfamiliar territory of building the same functionality in a block.

Incidentally my husband showed me his work website, in the public education space, the other day. It uses tables for layouts and is not likely to change anytime soon. The end of shortcodes may be farther away than it appears.

epiqueras commented 4 years ago

cc @annezazu

aaroncampbell commented 4 years ago

Wanted to weigh in here since I did so in Slack when this was brought up.

I see this as the beginning of the larger and long term phase out of shortcodes

I agree that not adding shortcode support to new functionality like this is a good (and necessary) step toward phasing them out. Hopefully it will encourage people to use newer better methods while working with this new system.

johnstonphilip commented 4 years ago

@azaozz I wonder if this GitHub issue would be a good place to provide more background details about this decision in more detail. While what you said here breifly touches on the "why"...

At this point shortcodes are the WP equivalent of using HTML tables for layout

...it can give the impression that they are bad simply because they are old, which isn't a great argument on its own. I wonder if we could communicate more of thinking behind this better. Would you be able to elaborate on the "why" behind shortcodes being phased out here? That way we can have a historical record of the thinking behind the decision, and people can reference what is said here if there are further questions or discussions.

I think communicating this more fully would go a long way to helping people understand.

DaisyOlsen commented 4 years ago

I would also like to know more about the decision making process.

Further, I think there are some related questions regarding user experience if some blocks cannot be used everywhere. In its current iteration, there doesn't appear to be any clear delineation between what is controlled by the content and what is the template part. I did some experiments with adding a block that was either completely or partially "removed" and then moving it around on the page and the result was not ideal.

annezazu commented 4 years ago

@johnstonphilip Thanks for flagging this as an opportunity to clarify vision. In digging into this, I found the following mentioned in the FAQ for Gutenberg:

https://developer.wordpress.org/block-editor/principles/faq/#should-i-move-shortcodes-to-content-blocks

However we see the block as an evolution of the [shortcode]. Instead of having to type out code, you can use the universal inserter tray to pick a block and get a richer interface for both configuring the block and previewing it. We would recommend people eventually upgrade their shortcodes to be blocks.

This made me notice that the FAQ is quite out of date and more sparse than it should be at this point! I opened this issue to start that update process: https://github.com/WordPress/gutenberg/issues/23763

To expand on what's in place though, I think there are three major reasons (and more I'm not thinking of right now) for why blocks are the future and shortcodes are being phased out long term:

Hope this provides more context :)

azaozz commented 4 years ago

...It uses tables for layouts and is not likely to change anytime soon. The end of shortcodes may be farther away than it appears.

...it can give the impression that they are bad simply because they are old.

Right, I've also built dozens of websites (for friends) using tables in the late 90's. Couple are still around I think. It's not that it's bad, or that it doesn't work, but using "old tech" comes with lots of incompatibilities and limits. Don't think anybody would ever think of using tables for a new site in 2020 :)

It's similar with shortcodes in WP. Have you looked at how shortcodes work? All the regex parsing of the HTML on every page load, the limitations, the edge cases... At the same time there are new, better ways to do everything shortcodes can do, and lots more.

I wonder if this GitHub issue would be a good place to provide more background...

Totally agree! There are better ways, my bad, sorry.

bobbingwide commented 3 years ago

I'm happily using shortcodes in my experimental Full Site Editing theme ( Fizzie ). I primarily done this as a temporary solution, until I can replace them with a block. In actual fact, I've written new shortcodes to deliver functionality that appears to be missing from the Full Site Editing blocks.

What am I missing here?

ndiego commented 3 years ago

I would like to provide some additional insight on this that I feel people might be overlooking. Shortcodes have been used for thousands fo different things. Yes, most shortcodes could easily become blocks. However, there are implementations that are impossible to become blocks.

Let's assume you have a shortcode the prints the current user's name. In a paragraph block, you could then do something like this "Hi there [user-name]!". Imagine this as a dynamic header on an Account page, or simply to personalize content throughout your website. While this works fine in posts, since shortcodes are rendered inside of post content, but it does not currently work in templates or template parts.

I do not see a way that this functionality could be replaced with blocks. Perhaps there is another way to add dynamic content within blocks, but I feel we need a solution for this. But, shortcodes are currently a viable solution that most WordPress users are already familiar with.

iandunn commented 2 years ago

I may be doing something wrong, but I do see the Shortcode block in the Inserter when editing block templates.

Shortcodes also work when I type them directly into a paragraph block (with the surrounding brackets), or add them directly to a {template}.html file.

That's the way it should be, IMO. Requiring people to re-write shortcodes or switch 3rd party plugins would make it harder to switch to a block theme in the real world. Supporting shortcodes provides a realistic migration path, so folks can upgrade their site one piece at a time.