In the ECommerce constructor capabilities checks are being used. In the data module, if the capabilities transient is absent a request is made to Hiive to update it. This expires after four hours.
From what I read, the capabilities checks here are running on every request, meaning every site is polling Hiive for capabilities every four hours.
This change moves the check behind admin_init and is_admin so the capabilities are only fetched when an admin is accessing /wp-admin. The actions and filters that were guarded by the capabilities are all related to admin UI changes (most obviously printing HTML).
[x] Linting and tests pass locally with my changes
[ ] I have added tests that prove my fix is effective or that my feature works
[ ] I have added necessary documentation (if appropriate)
Further comments
We are working on related changes in the data module to store the capabilities in an option rather than a transient, and in Hiive to push changes to the capabilities so polling is not necessary.
It's unclear to me if the failing tests are caused by this change. One of them is ~expected button not to exist, and the other could not find the my-products table.
Proposed changes
In the ECommerce constructor capabilities checks are being used. In the data module, if the capabilities transient is absent a request is made to Hiive to update it. This expires after four hours.
From what I read, the capabilities checks here are running on every request, meaning every site is polling Hiive for capabilities every four hours.
This change moves the check behind
admin_init
andis_admin
so the capabilities are only fetched when an admin is accessing/wp-admin
. The actions and filters that were guarded by the capabilities are all related to admin UI changes (most obviously printing HTML).https://github.com/newfold-labs/wp-module-ecommerce/commit/8b9c3716568d838345b559f3f1b83fc0ba30152f
https://jira.newfold.com/browse/PRESS0-1016
Type of Change
Video
Checklist
Further comments