Web-stories-wp: Web Stories Embed Shortcode

Created on 10 Jul 2020  Â·  11Comments  Â·  Source: google/web-stories-wp

Feature Description

Some users might not be using Gutenberg, but are instead using a page builder like Divi or Elementor that doesn't support blocks. Should we be adding shortcodes for those cases?

Alternatives Considered

Focus on Gutenberg blocks only.

Additional Context

Support request for this: #3086


_Do not alter or remove anything below. The following sections will be managed by moderators only._

Acceptance Criteria

Implementation Brief

  • Add new Google\Web_Stories\Shortcodes\Embed class

    • Public methods:

    • init(): calls add_shortcode( 'web_stories_embed', [ $this, 'render_shortcode' )

    • render_shortcode(): callback used for add_shortcode(). It will look largely similar to Embed_Block::render_block()

    • Supported attributes: width, height, url, poster, align, title (same as embed block, with same defaults)

    • Call init() in Plugin class

  • For the existing Web Stories Embed block, add a transform function that allows transforming instances of this shortcode into the embed block.
  • Add PHPUnit tests
  • Bonus: E2E tests for inserting and previewing a shortcode, as well as for transforming it into the block
Blocks WordPress P2 WP & Infra Enhancement Passed

Most helpful comment

@o-fernandez So, I was considering just pointing users to use <amp-story-player> markup directly as shown in the docs, but I've come to the realization that this wouldn't get them good results out of the box:

  • Issues with AMP validation when using the AMP plugin
  • No built-in responsiveness
  • Difficult to work with due to usage of CSS custom properties and requiring loading external assets

Then, I thought about just writing a simple shortcode mini-plugin for some users to install on their site. At that point I realized we could just as well incorporate it in the plugin, even if I'm not super fond of it — but it's better for the users.

I suggest for WP pod to tackle shortcode support for the next sprint.

It should be super easy to add.

All 11 comments

This should be pretty simply if we have the different render type working. It would be a matter of taking url param and rendering like the block.

Increasing the priority of this ticket given the popularity of this request (top requested feature during the Beta period)
@swissspidy @choumx and @amedina - for your consideration - when would be a good sprint to slot this into? Any PM/UX dependency?

Is "none" an option? 🙂 Because that's what I would strongly vote on.

We have to differentiate the context of all these requests a bit. Most of the time they want integrations with their page builder.

Shortcodes themselves are a dying feature in WordPress. Blocks are the way to go. So it doesn't really make sense to bet on this horse.

Integrations with page builders are a different beast, and should be something to tackle as part of our ecosystem work.

@swissspidy I think that integrations with page builders makes a ton of sense to start, and deprioritize shortcode.

Is there a workaround we can provide to users so they can get around this (some generic embedding mechanism that doesn't require them waiting for per-page builder effort?)

@o-fernandez So, I was considering just pointing users to use <amp-story-player> markup directly as shown in the docs, but I've come to the realization that this wouldn't get them good results out of the box:

  • Issues with AMP validation when using the AMP plugin
  • No built-in responsiveness
  • Difficult to work with due to usage of CSS custom properties and requiring loading external assets

Then, I thought about just writing a simple shortcode mini-plugin for some users to install on their site. At that point I realized we could just as well incorporate it in the plugin, even if I'm not super fond of it — but it's better for the users.

I suggest for WP pod to tackle shortcode support for the next sprint.

It should be super easy to add.

Thanks for thinking through the options, this makes sense to me. @choumx FYI and for consideration.

"Super easy to add" SGTM. :)

If it takes longer than a couple days of work, then we should consider doing a quick cost-benefit analysis WRT number of impacted users.

@spacedmonkey I added an IB in ticket above with an estimate. Curious to hear your feedback on it. Anything I missed? Feel free to adjust directly.

@swissspidy This should be extremely simple. Much of the logic in Embed_Block could be reused. In fact I believe that render_block could even be used for the add_shortcode callback.

The biggest piece of work here, is moving the code around and making it a little bit more generic to make it reuable.

Maybe much of the logic for Embed_Block could be moved to a new called Embed and Embed_Block and Embed_Shortcode could extend that.

If it takes longer than a couple days of work, then we should consider doing a quick cost-benefit analysis WRT number of impacted users.

tl;dr: The implementation of the shortcode(s) is super quick, but it requires some overdue/necessary refactoring on the PHP side. That refactoring would also need to happen once we start adding more blocks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

o-fernandez picture o-fernandez  Â·  4Comments

injainja picture injainja  Â·  4Comments

injainja picture injainja  Â·  4Comments

Maverick283 picture Maverick283  Â·  3Comments

o-fernandez picture o-fernandez  Â·  3Comments