sensei
sensei copied to clipboard
Add Sensei Home plugin update notices to REST API
Fixes #5738
Changes proposed in this Pull Request
- Adds a provider for notices to inject notices into Sensei Home's REST API endpoint.
- Adds a handler for injecting special Sensei Home notices either into
Sensei_Admin_Notices
(when available) or sneakily through the shared filter in the provider whenSensei_Admin_Notices
isn't available (Sensei Blocks). - Begrudgingly makes
Sensei_Admin_Notices
a singleton. It has a mix of classes that depend on it and would require several layers of DI. - We planned on having this be called
notifications
but switched tonotices
to match the rest of Sensei. - Adds the following notices:
- When an update is available for a free plugin or licensed and activated paid plugin.
- When an update is available for a paid plugin that isn't active an we're not sure the license status.
- When an update is available for a paid plugin but it doesn't have an active license.
Note: This doesn't add any additional license notices yet (when a license is about to expire, for example). It was getting too big so I thought I'd wait.
Testing instructions
- Try the following with various situations: Certificates downgraded, Sensei Pro deactivated, etc.
- You can also try this snippet to see what it is like with licensed Sensei Pro (future PR):
-
add_filter( 'sensei_home_is_plugin_licensed_sensei-pro', '__return_true' );
- Run:
curl -s -X GET --user jake:jakejake 'http://sensei.local/wp-json/sensei-internal/v1/home' | jq .notices
- Confirm output makes sense.
New/Updated Hooks
-
sensei_show_admin_notices_{$screen_id}
: Allows hiding admin notices on a particular screen. Used to hide on Sensei Home. -
sensei_home_is_plugin_licensed_{$plugin_slug}
: Allows Sensei Pro and Sensei Blocks to tell Sensei Home when their plugins have an active license.
Codecov Report
Merging #5900 (0e91080) into feature/new-onboarding-experience (58246cd) will increase coverage by
0.21%
. The diff coverage is76.11%
.
@@ Coverage Diff @@
## feature/new-onboarding-experience #5900 +/- ##
=======================================================================
+ Coverage 43.74% 43.96% +0.21%
- Complexity 9134 9184 +50
=======================================================================
Files 436 441 +5
Lines 32478 32679 +201
Branches 250 252 +2
=======================================================================
+ Hits 14208 14366 +158
- Misses 18086 18127 +41
- Partials 184 186 +2
Impacted Files | Coverage Δ | |
---|---|---|
includes/admin/class-sensei-home.php | 0.00% <0.00%> (-11.87%) |
:arrow_down: |
...s/admin/home/class-sensei-home-guides-provider.php | 100.00% <ø> (ø) |
|
...des/admin/home/class-sensei-home-news-provider.php | 100.00% <ø> (ø) |
|
...s/admin/home/class-sensei-home-remote-data-api.php | 95.08% <ø> (ø) |
|
includes/class-sensei-admin.php | 22.26% <ø> (-0.09%) |
:arrow_down: |
includes/class-sensei-autoloader.php | 14.58% <0.00%> (-0.32%) |
:arrow_down: |
includes/class-sensei-data-cleaner.php | 89.53% <ø> (ø) |
|
includes/class-sensei.php | 27.49% <0.00%> (-0.07%) |
:arrow_down: |
includes/admin/class-sensei-admin-notices.php | 48.41% <35.00%> (-3.48%) |
:arrow_down: |
...cludes/rest-api/class-sensei-rest-api-internal.php | 67.56% <50.00%> (-1.01%) |
:arrow_down: |
... and 17 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 928b588...0e91080. Read the comment docs.