-
Notifications
You must be signed in to change notification settings - Fork 15
Add a notice when requirements aren’t met #75
Conversation
This adds a notice in WordPress < 5.0 if Gutenberg is also below version 3.5.0 because Ramp doesn’t work with Gutenberg plugin that old anymore.
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.
Left some minor notes.
@@ -148,6 +162,11 @@ function gutenberg_ramp_require_gutenberg() { | |||
*/ | |||
gutenberg_ramp_require_gutenberg(); | |||
|
|||
if ( Gutenberg_Ramp_Compatibility_Check::should_check_compatibility() ) { | |||
$ramp_compatibility = new Gutenberg_Ramp_Compatibility_Check(); |
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.
Should we skip loading the rest of Ramp if the versions don't match?
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.
I don't think it's necessary. If Ramp isn't compatible - it doesn't do anything apart from attaching itself to 2 filters that will never be called, but it still does allow you to interact with ramp helper the you would normally.
I'm hesitant to change this because this is an edge case we're talking about. Refactoring the plugin to activate on a condition just because of an edge seems like a bit of overkill.
Ramp checks for whether it should be checking for compatibility at all, and if it should - it checks the compatibility and adds a notice - leaving the rest of the Ramp behavior as it was previously. It's simple, easy, and it works.
Call it gutenberg_ramp_get_validated_gutenberg_load_path instead of gutenberg_ramp_validated_gutenberg_load_path
And update the wording in the message
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.
🚢
This adds a notice in WordPress < 5.0 if Gutenberg is also below version 3.5.0 because Ramp doesn’t work with Gutenberg plugin that old anymore.
This is what the notice looks like:
The notice is a bit hacky in that it changes based on date. Anything after November 20, 2018 will append "Or upgrade to WordPress 5.0" in the notice based on a timestamp. An available WordPress update could be checked withThere's only 1 type of notice now when the PR is updated 🎉wp_version_check()
but I think it just adds too much overhead for such a small edge case that I opted for the simplest solution here, even though it may not be perfectly accurate. Let me know if you think the notice should rely onwp_version_check()
instead or even be worded differently.This PR also extracts code from
gutenberg_ramp_require_gutenberg()
into a new function:gutenberg_ramp_validated_gutenberg_load_path
- this is becauseapply_filters()
is used and the Gutenberg path can be modified, so instead of manually applying filters twice - I've moved the filter to a dedicated function.