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

Changing admin_init hook to init as it is not firing the promotions tab in side menu #354

Closed ramyakrishnai closed 4 weeks ago

ramyakrishnai commented 4 weeks ago

Changing admin_init hook to init as it is not firing the promotions tab in side menu

Proposed changes

Type of Change

Video

Checklist

Further comments

wpscholar commented 4 weeks ago

@ramyakrishnai - Just following up here. @BrianHenryIE mentioned that the init hook feels like the wrong hook, and admin_init feels more correct, given it automatically only applies in the backend context. I agree, but the issue is that the admin_menu hook fires before the admin_init hook (see https://developer.wordpress.org/apis/hooks/action-reference/). There doesn't seem to be a better hook that only applies to the admin area, so the solution you presented here is probably the best course of action.

wpscholar commented 4 weeks ago

This is the problem code here: https://github.com/newfold-labs/wp-module-ecommerce/blob/2e8bbee24011829b6ffb6e7c349fc1eab4c8f950/includes/ECommerce.php#L639