newfold-labs / wp-module-ecommerce

Next-generation eCommerce Experience for WordPress sites at Newfold Digital.
GNU General Public License v2.0
9 stars 3 forks source link

Move capabilities check behind `admin_init` and `is_admin` #351

Closed BrianHenryIE closed 4 weeks ago

BrianHenryIE commented 1 month ago

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 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).

https://github.com/newfold-labs/wp-module-ecommerce/commit/8b9c3716568d838345b559f3f1b83fc0ba30152f

https://jira.newfold.com/browse/PRESS0-1016

Type of Change

Video

Checklist

Further comments