Automattic / gutenberg-ramp

Control conditions under which Gutenberg loads - either from your theme code or from a UI
https://wordpress.org/plugins/gutenberg-ramp/
76 stars 15 forks source link

Add a notice when requirements aren’t met #75

Closed pyronaur closed 5 years ago

pyronaur commented 5 years ago

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:

screen shot 2018-11-01 at 5 47 34 pm

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 with 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 on wp_version_check() instead or even be worded differently. There's only 1 type of notice now when the PR is updated 🎉

This PR also extracts code from gutenberg_ramp_require_gutenberg() into a new function: gutenberg_ramp_validated_gutenberg_load_path - this is because apply_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.