Wp-calypso: Gutenberg: handle blocks that require a paid plan

Created on 10 Oct 2018  Â·  13Comments  Â·  Source: Automattic/wp-calypso

Some of the features that Core blocks provide are not available on WordPress.com Free plan. We need to find a way to handle those cases appropriately. The easiest way for the first iteration would be to hide the affected blocks, but we might also want to show upsell nudge instead of the usual placeholders (that won't be rendered on the front end, just visible in the editor).

Currently affected blocks:

  • [x] Audio
  • [x] Video

Fix proposed in D19590-code.

cc @shaunandrews @gwwar

[Goal] Gutenberg [Type] Task

Most helpful comment

we'll need server side checks to prevent rendering existing simple payment buttons when appropriate plan is not present

Unless things have changed for Simple Payments, I believe the first block iteration will serialize the existing shortcodes, so no additional work for rendering buttons on the published view should be needed.

All 13 comments

The Audio and Video blocks allow you to use a URL, rather than uploading. The File block—for some strange reason—doesn't allow you to use a URL and requires that you upload/pick a file from your library. (Made an issue in Gutenberg about that URL field: https://github.com/WordPress/gutenberg/issues/10521)

Once we have the Calypso media modal fully integrated, the audio and video tabs will show a nudge to upgrade to access media uploads:

image

However, its a little messy if you don't find those tabs. If you attempt to upload an media file on a free plan (without digging into any tabs) you'll get this cryptic error:

image

There's no mention of required plan upgrade, or anyway to find more information. That sucks. Perhaps we could change this message to mention a paid plan, and add a link to read more?

Right now, if you're using Gutenberg on WPcom wp-admin, and you try to upload an audio file, you'll get this different, cryptic message:

image

I'm not sure how this error is related, or if Gutenberg is misinterpreting an error from WPcom, but this is another area where we might need to add a better error message with a link to learn more about upgrading.

However, its a little messy if you don't find those tabs. If you attempt to upload an media file on a free plan (without digging into any tabs)

@shaunandrews I think this part is resolved now with #27891, since the appropriate tab will be opened and the others will be disabled.

Fix proposed in D19590-code.

The messages have now been changed to the following:

screenshot 2018-10-18 at 16 14 03

screenshot 2018-10-18 at 16 38 53

since the appropriate tab will be opened

Very cool. At some point we'll look at adding the upsell nudge directly in the card, but this is a great starting point.

messages have now been changed

Also very cool. Any chance we can add a link to learn more — maybe sending them to /plans/

Also very cool. Any chance we can add a link to learn more — maybe sending them to /plans/

I've looked into that already, but unfortunately I don't think it's possible with this approach, since error messages contain only plain text (even if passed, HTML will be escaped up the chain for security reasons, otherwise malicious translations could inject anything). I think we'd need to somehow override the default error message/block rendering for that, and there are no obvious extension points now. It will probably require writing our own custom versions of these blocks for WP.com (for nudges too).

We're working on simple payments which will require a plan check: #27998

I'm closing this for now since we landed an intermediate fix in D19590-code. We'll probably circle back to this when we have more time in order to create custom versions of core blocks in which we'll be able to add upgrade nudges, but that's not an immediate priority right now.

@sirreal let us know if there is some way that we can help. I suspect that your plan checking will be more straightforward since you can control the block's functionality completely.

Just mentioning this in case it's not already on your radar - I just realized that in addition to checks in editor, we'll need server side checks to prevent rendering existing simple payment buttons when appropriate plan is not present (e.g. business plan expiry/downgrade). We'll need to consider this for core blocks too, but probably not before we start making our custom versions of them (not an immediate priority I'd say).

we'll need server side checks to prevent rendering existing simple payment buttons when appropriate plan is not present

Unless things have changed for Simple Payments, I believe the first block iteration will serialize the existing shortcodes, so no additional work for rendering buttons on the published view should be needed.

Hey @vindl! It seems that this should be fixed per your comment here, but I got a user today complaining about this and when testing I see the error _"Sorry, this file type is not permitted for security reasons."_ Should we reopen this issue?

@carinapilar I was able to reproduce this so I'll reopen it and add it to our backlog. Thanks for reporting it!

Related: #33013

Similar case where we don't prompt for a plan upgrade when users try to upload video/audio files.

Was this page helpful?
0 / 5 - 0 ratings