mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
⚡️ Optimize PayPal SDK loading for block contexts
This commit is contained in:
parent
d6a130bb24
commit
47b57058fb
2 changed files with 15 additions and 5 deletions
|
@ -143,10 +143,15 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
function( array $components ) {
|
||||
$components[] = 'buttons';
|
||||
function( array $components, string $context ) {
|
||||
if ( str_ends_with( $context, '-block' ) ) {
|
||||
$components[] = 'buttons';
|
||||
}
|
||||
|
||||
return $components;
|
||||
}
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1594,10 +1594,15 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
|||
*
|
||||
* @internal Matches filter name in APM extension.
|
||||
*
|
||||
* @param array $components The array of components already registered.
|
||||
* @param array $components The array of components already registered.
|
||||
* @param string $context The SmartButton context.
|
||||
*/
|
||||
return array_unique(
|
||||
(array) apply_filters( 'woocommerce_paypal_payments_sdk_components_hook', $components )
|
||||
(array) apply_filters(
|
||||
'woocommerce_paypal_payments_sdk_components_hook',
|
||||
$components,
|
||||
$this->context()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue