Repository navigation
Recurring Payments: Use UpgradeNudge #13233
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cddd9d5
Memberships: Move get_status() method from REST API to Jetpack_Member…
ockham 33ba767
Recurring Payments: Set as unavailable is plan isn't sufficient
ockham ef10134
Better error handling
ockham 2a5efda
Aww screw this
ockham bbe4b67
Recurring Payments: Remove in-block upgrade notice
ockham 9714ade
Remove remaining references to shouldUpgrade
ockham fc2ae0f
Move stuff back
ockham d504402
Personal plan is sufficient
ockham a095fb9
Make $required_plan private
ockham 161bad0
Change comment wording to remove 'Memberships'
ockham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name (
register_gutenberg_block) feels a little generic vs the enclosed logic that only deals with a particular block (recurring-payments). I presume this is likely going to evolve into a more general block registration handler (?).That said, is the underlying logic here a little specific for a general memberships class (or what appears to be)? I prefer to decouple things like these early on if that's the case. Fear being, it can get cluttered with specific block type references sooner than later, and harder to refactor later (or nobody bothers to do so). I do see the class is only a few months old though, so it probably makes sense for
v1. 🤔Just curious on perspective - and the little I understand so far. :-)
p.s. I guess there is the option of moving "block registration" to a trait as an intermediate solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was thinking of this method to mean "register this Jetpack module's Gutenberg block". I didn't really want to do a method named
register_xyz_gutenberg_blockinside of a class namedXYZ, that seemed to redundant. (Okay, in this case, it would probably beJetpack_Memberships::register_recurring_payments_gutenberg_block()rather thanJetpack_Memberships::register_memberships_gutenberg_block(), but I'd argue thatmembershipsandrecurring_paymentsare mostly used synonymously in this file (and that the fact that two names exist for the same thing is mostly circumstantial).I didn't intend to evolve it into somehting more general, TBH. The logic driving whether a block should be registered, or whether it should be set as unavailable, and for what reason, is something fairly specific to each individual block.
I agree in principle; but as stated above, I'm not sure we can make things a lot more homogenous here. We have fairly indidivual Jetpack modules (a somewhat legacy concept) each of which does things quite differently, and we often have to find the best place to register the corresponding block (or set their (un)availability).
I've so far considered the
jetpack_register_block()andJetpack_Gutenberg::set_extension_unavailableour interface; modules can essentially use them at whatever point into their lifecycle (as long as it's soon enough for the consumer -- mostly the REST API -- to get accurate information). I guess for the purpose of the required plan check, we could require each module to provide information about the minimum plan it nees, and evaluate that information and register/set availability based on that.But this is complicated by the heterogenity of modules themselves. Note that not all modules come with a block; and not all blocks are tied to a module. Furthermore, a lot of modules exist both on JP and WP.com, but are implemented differently in both places.
And finally, there are other criteria besides required plan that can determine whether or not to show a block as available.
(That turned out a bit verbose 😅 I hope I didn't squash that -- commendable! -- idea of better consistency. If I'm beside the point, or if you had any other idea on how to do this, please let me know!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this was an excellent overview writeup of the problem space to explain the why's of the current setup. :-)
Would some of it deserve a place in the docs?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verbose is good. Thanks for the extra clarifications! :-)
I think the "modules" folder is a bit of a scary place for one to be (glad to see you mentioning "legacy" above)!
I can see this is following along how simple-payments is registering blocks. What I find missing I think is a contract binding these on common characteristics, or some abstraction of the things they do in common (which they apparently do - registering blocks for one). I believe you implied that in your answer above.
I don't, concretely, but I can throw some likely obvious ideas.
Modules seems to be an all-encompassing folder here - so I guess I would start with that - add some structure to the things we know (in this case, "modules that register blocks"). I think I would approach this along these lines:
Centralise the common logic elsewhere - provide a "yet another module" to handle block registration. I think I'd be happy if a module that registers a block defines some
optionsfor that block and only registers an action that takes care of the rest e.g.Fancy_Module_Namehandling block registration. Simple, and presumably of the form:Alternatively, I guess the more OO way - a parent class that these modules can extend from, contract block registration functions via an interface, a trait that these modules can mix in, etc. Just stating the obvious perhaps - but something along these lines! (assuming my naive understanding of any underlying complexities)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and my understanding is indeed fairly naive right now! I can hardly even tell how tightly-coupled the terms "membership" and "recurring-payments" are for one.