Fix the Apple Pay button in the editor

This commit is contained in:
Daniel Dudzic 2024-04-23 15:00:05 +02:00
parent d1b4d7721e
commit 436fd77587
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
6 changed files with 112 additions and 28 deletions

View file

@ -92,6 +92,7 @@ class ApplepayModule implements ModuleInterface {
}
$module->load_admin_assets( $c, $apple_payment_method );
$module->load_block_editor_assets( $c, $apple_payment_method );
},
1
);
@ -177,6 +178,13 @@ class ApplepayModule implements ModuleInterface {
}
}
);
add_action(
'enqueue_block_editor_assets',
function () use ( $c, $button ) {
$button->enqueue_admin_styles();
}
);
add_action(
'woocommerce_blocks_payment_method_type_registration',
function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void {
@ -207,6 +215,7 @@ class ApplepayModule implements ModuleInterface {
* @psalm-suppress UndefinedInterfaceMethod
*/
$button->enqueue_admin();
$button->enqueue_admin_styles();
}
);
@ -222,6 +231,21 @@ class ApplepayModule implements ModuleInterface {
);
}
public function load_block_editor_assets( ContainerInterface $c, ApplePayButton $button ): void {
// Enqueue backend scripts.
add_action(
'enqueue_block_editor_assets',
static function () use ( $c, $button ) {
/**
* Should add this to the ButtonInterface.
*
* @psalm-suppress UndefinedInterfaceMethod
*/
$button->enqueue_admin_styles();
}
);
}
/**
* Renders the Apple Pay buttons in the enabled places.
*