Skip to content

Gutenpack Subscription Block#10564

Merged
oskosk merged 19 commits intomasterfrom
gutenpack-subscriptions
Dec 14, 2018
Merged

Gutenpack Subscription Block#10564
oskosk merged 19 commits intomasterfrom
gutenpack-subscriptions

Conversation

@gititon
Copy link
Copy Markdown
Contributor

@gititon gititon commented Nov 7, 2018

This pull request adds the Gutenberg Subscription block.

The Subscription block invites visitors to sign up to be notified when there are new posts on a site.

When the block has focus in the editor, editors can toggle whether to show the number of subscribers in the block. When it doesn't have focus, editors will see the number of subscribers if they toggled that on.

Testing instructions:

Note that the block still is going to receive some CSS ❤️(cc @MichaelArestad) , so please focus on testing its functionality for now.

  1. Checkout this Jetpack branch and the corresponding Calypso branch,
    Gutenpack Subscription Block (Take two) wp-calypso#28887

  2. Run the command to build the Subscription block from your wp-calypso repo directory:

npm run sdk gutenberg client/gutenberg/extensions/presets/jetpack -- --output-dir=/<path_to_jetpack_repo>/_inc/blocks -w
  1. Connect Jetpack if it isn't connected

  2. Create a new post and add the Jetpack Subscription Block.

  3. Toggle the "show number of subscribers". Confirm that you see the number of subscribers when the block loses focus.

  4. Publish the post. Confirm that you see it on the frontend.

  5. Subscribe by using the block with a user or two (they will have to be a connected Jetpack user)

  6. Confirm that you see the number of subscribed users on the frontend (when the toggle was enabled for the block in the editor) and the editor when the block doesn't have focus.

Proposed changelog entry for your changes:

No changelog entry needed.

@gititon gititon added [Status] In Progress [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Nov 7, 2018
@gititon gititon requested a review from a team November 7, 2018 21:46
@jetpackbot
Copy link
Copy Markdown
Collaborator

jetpackbot commented Nov 7, 2018

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: January 10, 2019.
Scheduled code freeze: January 3, 2019

Generated by 🚫 dangerJS against 447d8f1

@jeherve jeherve added the [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. label Nov 8, 2018
@jeherve jeherve added this to the 6.8 milestone Nov 8, 2018
@gititon gititon changed the title Changes for subscription block (IN PROGRESS) Gutenpack Subscription Block Nov 13, 2018
@gititon gititon added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Nov 13, 2018
@gititon gititon requested a review from lezama November 13, 2018 15:57
@jeherve jeherve removed this from the 6.8 milestone Nov 15, 2018
@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Nov 26, 2018
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Switching this back to "In Progress", since the block is broken and some things will need to be updated in Jetpack to make it work:
Automattic/wp-calypso#28366 (review)

This PR will also need a rebase.

$show_subscribers_total = (bool) $instance['show_subscribers_total'];
$subscribers_total = $this->fetch_subscriber_count(); // Only used for the shortcode [total-subscribers]

if ( $instance['show_only_email_and_button'] ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we want to remove that information from the block? Wouldn't it be nice if folks could opt to use or customize that information?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This allows the published post/form to conform to @MichaelArestad 's design, https://wp.me/pafL3P-4w-p2

The idea was that anyone who wants to add things to their subscription form could simply add other block types above, below, to the side of it, etc. and include anything they want.

@matticbot
Copy link
Copy Markdown
Contributor

D21385-code. (newly created revision)

@gititon gititon force-pushed the gutenpack-subscriptions branch from d6066a3 to d936078 Compare November 29, 2018 22:38
@gititon gititon added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Nov 30, 2018
@jeherve jeherve added this to the 6.9 milestone Dec 3, 2018
$subscriptions = new Jetpack_Subscriptions_Widget();
$subscriber_info = $subscriptions->fetch_subscriber_count();
// Get the most up to date subscriber count when request is not a test
if ( ! defined( 'TESTING_IN_JETPACK' ) ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does Jetpack side knows when the site gets a new subscriber? could we delete the transient at that point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lezama I don't believe it does. There is an increment_subscriber_count function,

function increment_subscriber_count( $current_subs_array = array() ) {
, but I searched the Jetpack repo and don't see it invoked anywhere.

I believe the way it works is that subscribers confirm their subscription via the email they receive from wpcom, and the Jetpack site simply drops its transient and queries wpcom if the transient is more than an hour old to get the latest confirmed subscriber count.

@gititon
Copy link
Copy Markdown
Contributor Author

gititon commented Dec 7, 2018

This will now need a rebase, because of the changes mentioned in #10860, that cause the tests to fail.

@jeherve The branch has been rebased. Are there any issues or is the branch good to go? Thanks!

@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 10, 2018
$subscriptions = new Jetpack_Subscriptions_Widget();
$subscriber_info = $subscriptions->fetch_subscriber_count();
// Get the most up to date subscriber count when request is not a test
if ( ! defined( 'TESTING_IN_JETPACK' ) ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets use Jetpack_Constant class here instead.

Copy link
Copy Markdown
Contributor

@roccotripaldi roccotripaldi left a comment

Choose a reason for hiding this comment

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

Tests well!

@oskosk
Copy link
Copy Markdown
Contributor

oskosk commented Dec 14, 2018

After following the testing instructions I went and deactivated subscriptions. Then reloaded the frontend for the post I just wrote. I see this

image

On the editor, I refresh the page and I see this

image

I clicked Keep as html

image

Then saved the post and visited the frontend again

image
(Same as when I just deactivated subscriptions).

Then I activated subscriptions again and refreshed the post editor page.
The block is rendered like this on the editor.

image

image

Then I updated the post, thinking maybe something different would happen but it didn't. Seems like I cannot recover the regular block rendering now.

That said, everything that was stated in the testing instructions worked. The subscriptions count was there.

@oskosk oskosk dismissed jeherve’s stale review December 14, 2018 13:00

Feedback was addressed

@oskosk oskosk merged commit 940ccb3 into master Dec 14, 2018
@oskosk oskosk deleted the gutenpack-subscriptions branch December 14, 2018 13:00
@jeherve jeherve added [Status] Needs Testing We need to add this change to the testing call for this month's release [Status] Has Changelog and removed [Status] Needs Review This PR is ready for review. [Status] Needs Changelog [Status] Needs Testing We need to add this change to the testing call for this month's release labels Dec 14, 2018
jeherve added a commit that referenced this pull request Dec 19, 2018
jeherve added a commit that referenced this pull request Jan 3, 2019
jeherve added a commit that referenced this pull request Jan 3, 2019
* Add first version of the Changelog and testing list for 6.9

* Changelog: add #10710

* changelog: add #10538

* changelog: add #10741

* changelog: add #10749

* changelog: add #10664

* changelog: add #10224

* changelog: add #10788

* Changelog: add #10560

* Chanegelog: add #10812

* changelog: add #10556

* Changelog: add #10668

* Changelog: add #10846

* Changelog: add #10947

* Changelog: add #10962

* Changelog: add #10956

* Changelog: add #10940

* Changelog: add #10934

* Changelog: add #10912

* changelog: add #10866

* changelog: add #10924

* Changelog: add #10936

* Changelog: add #10833

* changelog: add #10867

* Changelog: add #10960

* Changelog: add #10888

* changelog: add #10840

* changelog: add #10972

* Changelog: add #10979

* changelog: add #10909

* Changelog: add #10958

* Changelog: add #10981

* Changelog: add #10564

* Changelog: add #10809

* Changelog: add #10982

* Changelog: add #10706

* Changelog: add #10978

* Changelog: add #10132

* Changelog: add #11022

* Changelog: add #11024

* Changelog: add #10875

* Changelog: add #11030

* Changelog: add #11053

* Changelog: add #10880

* Changelog: add #9359

* Changelog: add #11037

* Update block list

* Changelog: add #11060

* Changelog: add #10755

* changelog: add #11000

* Changelog: add #10786

* Changelog: add #10945

* Changelog: add #10597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack

Projects

None yet

Development

Successfully merging this pull request may close these issues.