Block registration: delay the get_gateways() call until after we're inside the hook callback
#765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This reworks the block payment method registration to get rid of the "translations loaded too early" notice.
Release: #763
Details
Before
Previously we were doing (pseudo-code):
woocommerce_blocks_payment_method_type_registrationhookThis was a problem because the
get_gateways()call loads the gateway classes, which loads the payment method title, which is translated. For example, this file: https://github.com/gdcorp-partners/woocommerce-gateway-authorize-net-cim/blob/3.10.10/src/class-wc-gateway-authorize-net-cim-credit-card.php#L57-L58 Themethod_titleand other properties are in the constructor.After
It's reworked like this:
woocommerce_blocks_payment_method_type_registrationhookIt's the exact same end logic, just ensures that we delay that
get_gateways()call until after init.QA
Before merge